September 07, 2010, 10:14:47 am *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Common questions answered here !
 
   Home   Help Search Login Register  
Pages: 1 [2]   Go Down
  Print  
Author Topic: Creating a list menu items according to the content item selected  (Read 4013 times)
trus
Freshman
*
Offline Offline

Posts: 28


« Reply #15 on: August 18, 2006, 04:10:00 pm »

Dear lstavinoha

Thank you very much for the reply.
i am going to send the results to and email and if its possible i am going to store them in the database. i think i am quite familiar with phpmyadmin.if you want me to do anything with phpmyadmin i think i can handle that part with your help.
Thank you
Logged
lstavinoha
Global Moderator
Freshman
*****
Offline Offline

Posts: 33



« Reply #16 on: August 22, 2006, 04:53:36 am »

Hi Trus,

Ok, let's start off with two tables, 1 to hold your room types and one to hold the relationship between categories and room types. In phpMyadmin you need to create the first table room_types.  It needs to have at least an id column for the primary key and a description column for the room type description.

The second table should have an id column, then a category_id, then a room_type_id.  This table will tell us which categories have which room types.

You can look at some of the Joomla/Mambo columns for some examples.  Once you have these two tables, post the schema here.

Thanks,
Larry
Logged
lstavinoha
Global Moderator
Freshman
*****
Offline Offline

Posts: 33



« Reply #17 on: August 23, 2006, 09:22:27 pm »

Trus, here is something you should be able to use.

Run this to create two tables and some sample data:
Code:
--
-- Table structure for table `jos_book_room_types`
--

CREATE TABLE `jos_book_room_types` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `description` varchar(100) NOT NULL default '',
  PRIMARY KEY  (`id`),
  KEY `idx_description` (`description`)
);

--
-- Dumping data for table `jos_book_room_types`
--

INSERT INTO `jos_book_room_types` VALUES (1, 'Economy');
INSERT INTO `jos_book_room_types` VALUES (2, 'Normal');
INSERT INTO `jos_book_room_types` VALUES (3, 'Suite');
INSERT INTO `jos_book_room_types` VALUES (4, 'Kitchenette');
INSERT INTO `jos_book_room_types` VALUES (5, 'Business Suite');
INSERT INTO `jos_book_room_types` VALUES (6, 'Honeymoon Suite');
INSERT INTO `jos_book_room_types` VALUES (7, 'Penthouse');

-- --------------------------------------------------------

--
-- Table structure for table `jos_book_room_category`
--

CREATE TABLE `jos_book_room_categories` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `catid` int(11) unsigned NOT NULL default '0',
  `roomid` int(11) unsigned NOT NULL default '0',
  PRIMARY KEY  (`id`),
  KEY `idx_catid` (`catid`)
);

--
-- Dumping data for table `jos_book_room_categories`
--

INSERT INTO `jos_book_room_categories` VALUES (1, 1, 1);
INSERT INTO `jos_book_room_categories` VALUES (2, 1, 2);
INSERT INTO `jos_book_room_categories` VALUES (3, 1, 3);
INSERT INTO `jos_book_room_categories` VALUES (4, 2, 4);
INSERT INTO `jos_book_room_categories` VALUES (5, 2, 6);
INSERT INTO `jos_book_room_categories` VALUES (6, 2, 7);
INSERT INTO `jos_book_room_categories` VALUES (7, 1, 5);

-- --------------------------------------------------------

Now, in your form pieces before form, add this line above your javascript codes:
Code:
// load the standard form creation utilities
$this->execPieceByName('ff_InitLib');

Now, in the room_type select list, add this code to the options section:
Code:
<?php
$book_catid 
ff_getParam('ff_param_catid'0);
$book_catid intval($book_catid);

$rows ff_select(
            
"select jos_book_room_types.id, description ".
            
"from jos_book_room_types ".
            
"join jos_book_room_categories ".
            
"on jos_book_room_types.id = jos_book_room_categories.roomid ".
            
"where jos_book_room_categories.catid = $book_catid ".
            
"order by jos_book_room_types.id"
        
);
$flag 0;
$list '';
if (!
is_null($rows))
    foreach (
$rows as $row)
            
$list .= "0;$row->description;$row->id\r\n";
return 
"1;Select Room Type;book_sel_roomid\r\n".$list;
?>

Now, by changing $book_catid between 1 and 2, you will see different values.  You can do this fromm a menu or a mambot calling the form, or just edit the code.

This should help you on your way.

HTH,
Larry
Logged
trus
Freshman
*
Offline Offline

Posts: 28


« Reply #18 on: August 26, 2006, 09:31:50 am »

Hey

Thank you very much lary.
Thank you for your great work. but its not still not working for me. i think there i am doing something wrong.
here is how i did it.

i have created the two tables in my database by running the sql. working fine.
then i have added the code in the before form field and added the PHP code in the options field of select list.

But there is no item shown in the list.

Did i missed something on your expalnation?

Thank you
ameen
Logged
lstavinoha
Global Moderator
Freshman
*****
Offline Offline

Posts: 33



« Reply #19 on: August 26, 2006, 01:41:51 pm »

In order for the query to acutally work, the variable $book_catid has to have a value that exists in the jos_book_room_categories.catid column.  In the samples I have given, that will have to be either a 1 or a 2.

The line $book_catid = ff_getParam('ff_param_catid', 0); in the code is trying to get the value of a parameter passed to the form.  If it doesn't find the parameter, then it uses 0.  In this sample using a value of 0 would result in no records.

So, if you change the 0 in "$book_catid = ff_getParam('ff_param_catid', 0);" to a 1 or 2, you can see the rows on the backend, but this is equivalent to hardcoding.  Go ahead and try it to make sure it is working.

After seeing that this works, you want to figure out how to set this value "$book_catid" from the front end.  You can pass a parameter if you are using the mambot and have the form embedded in content.  You could also get it from the url or a menu.  I'm not sure what the layout and usage of the form is going to be on your site, so it is hard to suggest which way to use it.

HTH,
Larry


Logged
trus
Freshman
*
Offline Offline

Posts: 28


« Reply #20 on: August 28, 2006, 10:32:43 am »

Hello Larry

Thank you very much for the script. its working now.
My form is included in the page using mambot and do the script search for the url param if i put zero there in order to get which page the user is now and pass the categories. and how do i enter my own room types into the database? i should manually enter the data using phpmyadmin.

Thank you for the great help.
trus
Logged
fvds
Administrator
Living Legend
*****
Offline Offline

Posts: 2322



WWW
« Reply #21 on: August 28, 2006, 10:43:57 am »

Hi Trus,

for maintaining your tables take a look at Boldee's package at http://www.facileforms.biz/forum/index.php/board,17.0.html.
It's a good starter for creating forms to maintain database tables. You can ofcourse adjust all forms and code to your own needs...
Logged

Fred

Please read the forum rules first!
Please do not use PM for generic questions!
Visit me at OverTheWeb
trus
Freshman
*
Offline Offline

Posts: 28


« Reply #22 on: September 07, 2006, 03:46:51 pm »

Hello Larry

Thank you very much for your help.
Is there any way that i can get the page or item ID automatically. so then i can load the room types according to that ID. and i think i should relate the room type ID and content item id.

Thank you
trus
Logged
lstavinoha
Global Moderator
Freshman
*****
Offline Offline

Posts: 33



« Reply #23 on: September 08, 2006, 04:56:25 am »

Hi Trus,

All you need to do is change the line
Code:
$book_catid = ff_getParam('ff_param_catid', 0);
to
Code:
$book_catid = ff_getParam(ff_contentid, 0);

Then, in the jos_book_room_categories.catid column, put the content id of the content item instead of the 1 or 2 that I used in the example.

Then you would just use the mambot like {FacileForms: Booking}.  You do need to be using the mambot 1.4.6f (and up) as facile said.

HTH,
Larry
Logged
trus
Freshman
*
Offline Offline

Posts: 28


« Reply #24 on: September 13, 2006, 09:18:44 am »

Hi Larry

Thank you very much.
But the code is not working now?
i have changed the code as you explained.
and i have changed the catid in the database table. content items have auto incriminent id so from where i can get the id of the content item.
i have compied it from the link.
please reply me soon.

Thank you
Logged
Pages: 1 [2]   Go Up
  Print  
 
Jump to:  

Powered by SMF © 2001-2006 Lewis Media
| Terms of Use | Privacy | Sitemap |