Forums

Link drop down to sections and categories

Camastr 28 Apr, 2009
Hi,

Is it possible to create a form which links directly into the jos_content table instead of creating my own?

If not

Is it possible to link 2 drop down boxes in the form wizard stage to the categories and sections i have in my jos_sections and jos_categories table?

If either of these are possible, what would be the best way of doing it? The problem im finding with this plugin is my coding is not too great. Thanks if u can help
GreyHead 28 Apr, 2009
Hi Camastr,

Yes, - download and restore the submit_content.cfbak from from the Dowmloads area here.

You'll find several threads in the forums here on using it.

Bob
Camastr 29 Apr, 2009
Hi Greyhead,

Not the best start for me at all. Ive seached high and low for submitcontent.cfbak. Especially in the download section above. I can see it exists in the forum discussions, but have no way of navigating to it? What is the URL to download your suggested .cfbak file?

regards

camastr
GreyHead 29 Apr, 2009
Hi Camastr,

It's here - well hidden in the Downloads

Bob
Camastr 29 Apr, 2009
Excellent! Thanks for the pointer GreyHead. And i thought i had searched through every page, well except that one.🙂

Ok, so the form is up, im publishing to the #__content and emails are flying through. nice!
I replaced the editor with a text field and used 2 drop downs for [Sections] and [Categories] in the form, positioned neatly.
Category dropdown does exactly what it says on the tin, it shows a list of categories. Im happy with that.
Sections however 😟 i can only display a fixed variable in the drop down . e.g. this code taken from your forum shows a cat with ID 1

<div>
<label class="cf_label">Location:</label>
<?php
echo JHTML::_('list.section', 'field_name');
?>
</br>
<?php
echo JHTML::_('list.category', 'field_name', '1');
?>
</div>


The problem i have is to do with that '1');. Id like to relate the categories in my second drop down to the section i have chosen in the first drop down. I read the 2 things you must do to on the 'submitcontent.cfbak' landing page however i didnt quite understand the 'onsubmit()' thing i should do to hold the values of Sections and categories or if this is what i need to do? I would appreciate a little pointer to get this working. its soooo close😀

I have tried replacing the '1' with 'section_id' This did not list anything other than 'select category'

The other problem i have is. If you select a selection from the drop down it does not publish this information. It will only publish the title, content, alias name etc. How do you make sure the selection im picking (likewise with the category, when its working) sticks to the _content table in my Database.


thanks in advance
Camastr
Max_admin 30 Apr, 2009
Hi Camastr,

I will start with the 2nd problem, the dropdwon code should be:

echo JHTML::_('list.section', 'section_id');


and

echo JHTML::_('list.category', 'catid', '1');


the 2nd one will publish all categories is section 1, if you want the 2 dropdowns related then this some AJAX or JS, I suggest you upgrade to RC4.2 when its out then lets continue this post so that I can show you how to use the new features in RC4.2 to do this with ease!

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Camastr 30 Apr, 2009

if you want the 2 dropdowns related then this some AJAX or JS, I suggest you upgrade to RC4.2 when its out then lets continue this post so that I can show you how to use the new features in RC4.2 to do this with ease!



Sure, i will keep this post alive throughout the development of CF. It is possible you can use the login form of http://www.abbreviationsmart.com as a working example/case study.

Just to confuse things, in my last post i said

Category dropdown does exactly what it says on the tin, it shows a list of categories. Im happy with that.
Sections however😟 i can only display a fixed variable in the drop down

Well, it is the sections that currently works fine and the Categories that need linking to the Sections. I wrote that the wrong way round. Sorry about that.

I was however expecting a php solution. I think while you develop RC4.2, i will play about with creating a variable. Storing the section ID in the var and executing the Category ID WHERE CATID = SECID. I understand the theory of programming im just new to the php syntax. Im sure its not impossible. The race is on🙂 (ur task is much bigger tho)

Camastr
Max_admin 03 May, 2009
Hi Camastr,

RC5 is out and you can add onchange event to the sections dropdown to AJAX get a URL like this:
index2.php?option=com_chronocontact&chronoformname=form_name&task=extra

and in the extra1 box you can use some PHP code to load a new categories dropdown for you!

let me know if you are interested and I will write a full example, alittle busy today!

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Camastr 04 May, 2009
Hi Max,
Sorry for the belated response, i have to admit, i did not expect a new release so prompt. Ive downloaded it and shall get things up and going hopefully Tuesday/Wednesday. Like usual my plate is heaped 😲 Im still needing to achieve the one to many relationship between sec and cat however i need to see CFv5 in action before i can query any further. I must admit, this is a great product. Ajax does appear to be the way forward these days.


Regards
Camastr

PS once this is up and running i wouldnt mind making a suggestion that would make this product stand out WAY above the rest (even though it already does). One thing at a time though as not to confuse the thread with a split conversation.
Camastr 15 May, 2009
Hi Max,
It took way longer than expected to get my content ready for my site. Anyhow, im jet set go now and would appreciate some help on linking that category to the section chosen in the dropdowns. Ive successfully installed ChronoForms_V3.1_RC5.0.
Max_admin 19 May, 2009
Hi Camastr,

first step is to have Chronoforms validation or "load files" set to yes so that mootools is loaded!

we need to edit the section list select box to this code:

<?php echo JHTMLList::section( 'section_id', '', 'onChange="LoadCats()"') ; ?>


next step is to add this code to the JS box:

function LoadCats() {
	var url = "index2.php?option=com_chronocontact&chronoformname=form_name_here&task=extra§ionid" + $('section_id').value;
	new Ajax(url, {
		method: 'get',
		update: $('cats_div')
	}).request();	
}


now, in the Extra1 code box we need to place this code:


<?php 
global $mainframe;
echo JHTMLList::category('catid', $_GET['section_id']) ;
$mainframe->close();
?>


This code is really tricky and needs testing and I didn't so that please be patient and let me know the results, we will walk through it till we get it working!😉

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Camastr 19 May, 2009
Hi Max,
Ive left the publish option up on http://www.abbreviationsmart.com . Ive enabled uploads, changed cat and sec drop down to

<?php echo JHTMLList::section( 'section_id', '', 'onChange="LoadCats()"') ; ?>
</br>
<?php echo JHTML::_('list.category', 'field_name', '1'); ?>


copied in the LoadCats JS in JS section and changed your
form_name_here
to
submitcontent

I then pasted in the extra code1 and saved. As you will see. I get this

Fatal error: Class 'JHTMLList' not found in /home/content/b/a/m/bamastr/html/abb/components/com_chronocontact/chronocontact.html.php(153) : eval()'d code on line 25

and the first field. Any ideas?

Camastr
Camastr 19 May, 2009
Sorry, I have also changed the cat code to this.
echo JHTML::_('list.category', 'catid', '1');
Max_admin 20 May, 2009
Hi Camastr,

Does this code shows a categories dropdown correctly ?
    echo JHTML::_('list.category', 'catid', '1');


if so then please change this line:
<?php echo JHTMLList::section( 'section_id', '', 'onChange="LoadCats()"') ; ?>

to
<?php echo JHTML::_( 'list.section','section_id', '', 'onChange="LoadCats()"') ; ?>


then test and let me know!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Camastr 20 May, 2009
Max,


The form is backup. But unfortunately you can see the two drop downs dont appear to be related. http://www.abbreviationsmart.com/index.php?option=com_chronocontact&Itemid=2

Just to confirm the code now is


<?php echo JHTML::_( 'list.section','section_id', '', 'onChange="LoadCats()"') ; ?>
</br>
<?php echo JHTML::_('list.category', 'catid', '1'); ?>
</div>


The categories loaded are infact all from Section 1. Or the value stated nect to catid
Max_admin 21 May, 2009
I see, 2 problems, #1 we missed a = sign, at this code:
    function LoadCats() {
       var url = "index2.php?option=com_chronocontact&chronoformname=form_name_here&task=extra§ionid" + $('section_id').value;
       new Ajax(url, {
          method: 'get',
          update: $('cats_div')
       }).request();   
    }


it should be
    function LoadCats() {
       var url = "index2.php?option=com_chronocontact&chronoformname=form_name_here&task=extra§ionid=" + $('section_id').value;
       new Ajax(url, {
          method: 'get',
          update: $('cats_div')
       }).request();   
    }

notet he sign added after sectionid

#2-, in the Extra1 box we will change
    <?php
    global $mainframe;
    echo JHTMLList::category('catid', $_GET['section_id']) ;
    $mainframe->close();
    ?>

to
<?php echo JHTML::_('list.category', 'catid', $_GET['section_id']); ?>


then retest!

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Max_admin 21 May, 2009
and don't forget to add the categories dropdown in your form inside a div with id="cats_div"

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Camastr 22 May, 2009
oh no! page 2! where did that come form? ive been sat on page 1 waiting for your reply for 2 days😶 ill get onto this on Saturday
Max_admin 24 May, 2009

oh no! page 2! where did that come form? ive been sat on page 1 waiting for your reply for 2 days😶 ill get onto this on Saturday



Hi Camastr,

I didn't mention anything about "page2"🙂

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Camastr 26 May, 2009
Max,
right! ive added the missing '=' in the JS and replaced extracode1 to the one liner you suggested.

Im not sure what you meant by

and don't forget to add the categories dropdown in your form inside a div with id="cats_div"



so i tried nothing, which didnt work🙂
i tired
<div>
<label class="cf_label">Location:</label>

<?php echo JHTML::_( 'list.section','section_id', '', 'onChange="LoadCats()"') ; ?>
</br>
<?php echo JHTML::_('list.category', 'catid', 'id=cats_div'); ?>
</div>


and

<div>
<label class="cf_label">Location:</label>

<?php echo JHTML::_( 'list.section','section_id', '', 'onChange="LoadCats()"') ; ?>
</br>
<?php echo JHTML::_('list.category', 'catid', 'cats_div'); ?>
</div>



what is it you mean by adding the categories dropdown in your form inside a div with id="cats_div"?

thanks once again
Camastr
Max_admin 28 May, 2009
Hi Camastr,

this code:
<?php echo JHTML::_('list.category', 'catid', 'id=cats_div'); ?>


should be like this:

<div id="cats_div">
<?php echo JHTML::_('list.category', 'catid', 'id=cats_div'); ?>
</div>


let me know!

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Camastr 28 May, 2009
This one is oddface-meh-blank


<div>
<label class="cf_label">Location:</label>

<?php echo JHTML::_( 'list.section','section_id', '', 'onChange="LoadCats()"') ; ?>

</div>

<div id="cats_div">
<?php echo JHTML::_('list.category', 'catid', 'id=cats_div'); ?>
</div>


and


<div id="cats_div">
<label class="cf_label">Location:</label>

<?php echo JHTML::_( 'list.section','section_id', '', 'onChange="LoadCats()"') ; ?>
<br>
<?php echo JHTML::_('list.category', 'catid', 'id=cats_div'); ?>
</div>



It appears the actual template changes when you select a category and the category drop down disappears.
http://www.abbreviationsmart.com/index.php?option=com_chronocontact&Itemid=2
very odd
Max_admin 01 Jun, 2009
Hi Camastr,

Sorry, some fixes needed!

the extra code should be:
<?php echo JHTML::_('list.category', 'catid', $_GET['sectionid']); ?>


and this code :
        function LoadCats() {
           var url = "index2.php?option=com_chronocontact&chronoformname=form_name_here&task=extra§ionid=" + $('section_id').value;
           new Ajax(url, {
              method: 'get',
              update: $('cats_div')
           }).request();   
        }


should now be:
        function LoadCats() {
           var url = "index2.php?option=com_chronocontact&chronoformname=form_name_here&task=extra&format=raw§ionid=" + $('section_id').value;
           new Ajax(url, {
              method: 'get',
              update: $('cats_div')
           }).request();   
        }


Please let me know!

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.