populate a fieldlist with joomla articles title

  • netenvie
  • netenvie's Avatar Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • If you fail, try again and fail better !
  • Posts: 132
  • Thank you received: 5

netenvie created the topic: populate a fieldlist with joomla articles title

Hi,
As said in title i want a form field (list) and i need to populate (fill) list with all articles title from a specified Joomla category.
IS there a way to do that please ?
#233908
  • Posts: 2561
  • Karma: 87
  • Thank you received: 344

mihaela replied the topic: populate a fieldlist with joomla articles title

Hello,

I have answered on the ticket that you have created so please take a look at the answer there.

Regards,

Mihaela
#233932
  • Posts: 29
  • Thank you received: 0

greg.o replied the topic: populate a fieldlist with joomla articles title

Hello,

I am also very interested in this process. Can you communicate it to me?

Thank you!
#234930
  • Posts: 2561
  • Karma: 87
  • Thank you received: 344

mihaela replied the topic: populate a fieldlist with joomla articles title

Hello,

You can try to fill in select list putting the following code in Before Form pieces as explained in this piece of documentation crosstec.org/en/support/online-documenta...ct-list-from-db.html .
$this->execPieceByName('ff_InitLib');
$db = JFactory::getDBO();
$db->setQuery('Select title From #__content Where catid=2 OR catid=3'); 
 
$result = $db->loadColumn(); //load the result from the query
$test = "";
for ($i = 0; $i < count($result); $i++)
{
     $test .= "0;".$result[$i].";".$result[$i]."\n";
}
 
function ff_setSelectList($name, $value)
{
     global $ff_processor;
     for ($r = 0; $r < $ff_processor->rowcount; $r++)
     {
          $row =& $ff_processor->rows[$r];
          if ($row->name==$name)
          $row->data2 = $value;
          unset($row);
     } // for
} // ff_setSelectList
ff_setSelectList('fieldname', $test);
NOTE: Make sure to replace fieldname with the name of the form select list element that you wish to fill in with possible options.

This code will take all articles with "catid" equal to 2 or 3.

Let me know whether this helped to achieve what you want.

Regards,

Mihaela
#234931
The following user(s) said Thank You: greg.o
  • netenvie
  • netenvie's Avatar Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • If you fail, try again and fail better !
  • Posts: 132
  • Thank you received: 5

netenvie replied the topic: populate a fieldlist with joomla articles title

Hello,
Go to form advanced properties -> more options
Then go to form pieces and paste that in before form :
$this->execPieceByName('ff_InitLib');
$db = JFactory::getDBO();

// Customize this sql request :
$db->setQuery('Select title From #__content Where catid=1 OR catid=2 order by title'); 
 
$result = $db->loadColumn(); //load the result from the query
$selectlistv = "";

// Customize choice text :
$selectlistv .= "0;Choose something ...;choixf\n";
for ($i = 0; $i < count($result); $i++)
{
     $selectlistv .= "0;".$result[$i].";".$result[$i]."\n";
}
function ff_setSelectList($name, $value)
{
     global $ff_processor;
     for ($r = 0; $r < $ff_processor->rowcount; $r++)
     {
          $row =& $ff_processor->rows[$r];
          if ($row->name==$name)
          $row->data2 = $value;
          unset($row);
     } // for
} // ff_setSelectList

// Customize yourfieldname
ff_setSelectList('yourfieldname', $selectlistv);
#234932
The following user(s) said Thank You: greg.o, mihaela
  • Posts: 2561
  • Karma: 87
  • Thank you received: 344

mihaela replied the topic: populate a fieldlist with joomla articles title

Dear "Netenvie",

thank you for sharing, I have just suggested the same to the user.

Best regards,

Mihaela
#234933
The following user(s) said Thank You: greg.o
Moderators: ForumSupporttomeperica
Time to create page: 0.068 seconds

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans, templates and icon packs!

Get Your Subscription Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99 for just 49! (Summer Sale)

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here