Forums

chronoform and articles name of joomla

simonetta 02 Apr, 2011
i create a website where the article of joomla are a courses, i need and i dont' know if is possible to do this:
when the user is in the article (courses) can subscribe register to it, with a standard form of chronoform :name, email pass etc ..but in the form i need that the first field must be the name of the articles of joomla automatically ( the name of the courses) ..i can do this ? and if yes can help me?
simonetta 03 Apr, 2011
i think that we can insert the latest news of joomla in a dropdown that include automatically the last item of a spefic category ( the name of the courses ) but i dont' know how and if is possible
thanks
GreyHead 04 Apr, 2011
Hi simonetta ,

This code will get you a drop-down with a list of article id's and titles in a specific category:
<?php
$db =& JFactory::getDBO();
$query = "
    SELECT `id`, `title`
        FROM `#__content`
        WHERE `catid` = '99'
        ORDER BY `publish_up` DESC ;
";
$db->setQuery($query);
$data = $db->loadObjectList();
$options = array('' => '==?==');
foreach ( $data as $d ) {
  $options[] = "<option value='{$d->id}' >{$d->title}</option>";
}
?>
. . .
<select . . .>
<?php echo implode('', $options); ?>
</select>
. . .


Bob
simonetta 07 Apr, 2011
i'm sorry bob ..i have tried and tried again.. but appear only a dropdown blank
i have insert this in the code form with javascritp
<?php
$db =& JFactory::getDBO();
$query = "SELECT `id`, `title`
FROM `#__content`
WHERE `catid` = '39'
ORDER BY `publish_up` DESC ;";
$db->setQuery($query);
$data = $db->loadObjectList();
$options = array('' => '==?==');
foreach ( $data as $d ) {
$options[] = "<option value='{$d->id}' >{$d->title}</option>";"
?>


in the code form html i insert
<select name="select" size="1" id="select">
<?php echo implode('', $options); ?>
</select>

</tr>
</table>
<div align="center">{imageverification}
</div>

<p align="center">
<input name="Submit" type="submit" class="chronoform" value="Invia" /></p></td>
</tr>
</table>


sorry but i dont' know the php🙂 and so i dont' know where the mistake
GreyHead 07 Apr, 2011
Hi simonetta,

There's a } missing at the end:
  $options[] = "<option value='{$d->id}' >{$d->title}</option>";"
} // <-- add this bracket
?>


Bob
simonetta 07 Apr, 2011
nothing
<?php
$db =& JFactory::getDBO();
$query = "SELECT `id`, `title`
        FROM `#__content`
        WHERE `catid` = '39'
        ORDER BY `publish_up` DESC ;";
$db->setQuery($query);
$data = $db->loadObjectList();
$options = array('' => '==?==');
foreach ( $data as $d ) {
  $options[] = "<option value='{$d->id}' >{$d->title}</option>";"
} 
?>  


but the dropdown is blank ...
i modify the category id ..
and add the }
iput the code in the section form javascript
and in the form html this
 <select name="select">
            <?php echo implode('', $options); ?>
            </select>
 
        </tr>
      </table>      
      <div align="center">{imageverification}
</div>
        <p align="center">
    <input name="Submit" type="submit" class="chronoform" value="Invia" /></p></td>
  </tr>
</table>


you can see others mistakes bob?
tks
GreyHead 08 Apr, 2011
Hi simonetta,

iput the code in the section form javascript


But it's PHP, not JavaScript and needs to go in the Form HTML box. I'm sorry, I didn't notice that in your earlier post.

Bob
simonetta 08 Apr, 2011
hi bob
i put this code in the html form
<?php
$db =& JFactory::getDBO();
$query = "SELECT `id`, `title`
        FROM `#__content`
        WHERE `catid` = '39'
        ORDER BY `publish_up` DESC ;";
$db->setQuery($query);
$data = $db->loadObjectList();
$options = array('' => '==?==');
foreach ( $data as $d ) {
  $options[] = "<option value='{$d->id}' >{$d->title}</option>";"
} 
?>
 <select name="select">
            <?php echo implode('', $options); ?>
            </select>
 
        </tr>
      </table>      
      <div align="center">{imageverification}
</div>
        <p align="center">
    <input name="Submit" type="submit" class="chronoform" value="Invia" /></p></td>
  </tr>
</table>

but now disappear the dropdown blank too , i see only powered by chronoform but nothing yet
GreyHead 08 Apr, 2011
Hi simonetta,

Sorry, I left an extra " on the end of this line
  $options[] = "<option value='{$d->id}' >{$d->title}</option>";

Bob
simonetta 08 Apr, 2011
:) thanks bob for your help
now it work
thanks very much
simonetta 10 Apr, 2011
grey i need your help again
..in this way ..in the form are shows all the item ..published and no ....how can i insert the query to show onlye the item published or that appear on home page?
i think i have to insert AND published ='1' but i dont' know where

the other problem is that in the email i received appear only the number of the items but not the title
tks
GreyHead 11 Apr, 2011
Hi simonetta,

WHERE `catid` = '39' AND `published` = 1

Bob
simonetta 11 Apr, 2011
sorry but not work, the dropdown now is blank
<?php
$db =& JFactory::getDBO();
$query = "SELECT `id`, `title`
FROM `#__content`
WHERE `catid` = '39' AND `published` = 1
ORDER BY `publish_up` DESC ;";
$db->setQuery($query);
$data = $db->loadObjectList();
$options = array('' => '==?==');
foreach ( $data as $d ) {
$options[] = "<option value='{$d->id}' >{$d->title}</option>";
}
?>

the second question is that when i recived the form by email ..there are not the title of the articles but only the number
thanks bob
GreyHead 11 Apr, 2011
Hi simonetta,

Are there any articles WHERE `catid` = '39' AND `published` = 1 ??? The SQL looks good so the next thing to check is to test in PHPMyAdmin to see what results it should give*.

And, yes, this code returns the article ID. You haven't actually said what you want to do with the result and the ID is the most useful value to return.

You can return the Title if you prefer; or look the title up from the ID before the email is sent.

Bob

* I just checked the jos_contents table and there is no `published` column. It is `state` in this table.
simonetta 11 Apr, 2011
this is the code that work
<?php
$db =& JFactory::getDBO();
$query = "SELECT `id`, `title`
FROM `#__content`
WHERE `catid` = '39' AND `state` = 1
ORDER BY `publish_up` DESC ;";
$db->setQuery($query);
$data = $db->loadObjectList();
$options = array('' => '==?==');
foreach ( $data as $d ) {
$options[] = "<option value='{$d->title}' >{$d->title}</option>";
}
?>

<select name="select2" id="select">
<?php echo implode('', $options); ?>
</select>

to receive the title in the email of the form i modify this
$options[] = "<option value='{$d->title}' >{$d->title}</option>";
work ..but is right?
thanks
GreyHead 11 Apr, 2011
Hi simonetta,

Try it and see.

Bob
simonetta 11 Apr, 2011
i have tried and it work🙂
thank very much bob for your patience
This topic is locked and no more replies can be posted.