Modifying Universal Module to Accept Form Entry

More
11 years 7 months ago #28342 by sadie199
I'm trying to modify the Flexicontent Universal Module to accept a form submission. In other words, I want to use the tag scope to display information, but I want the tags used to be selected by the user in a multi-select form.

So, the user will see a list of available tags, select two on which to base the tag scope display of the module.

In helper.php, the line that pulls the tag_ids parameter from the database appears to be:

// tags scope parameters
$method_tags = (int)$params->get('method_tags', 1);
$tag_ids = $params->get('tag_ids', array());
$tag_ids = (!is_array($tag_ids)) ? array($tag_ids) : $tag_ids ;

Can I modify this line so that it uses the form data submitted instead of pulling from the database? Something along the lines of $_POST[tag_ids]?

Thank you!

Please Log in or Create an account to join the conversation.

More
11 years 7 months ago #28372 by ggppdk
i am sorry, i have read your original message wrongly,
I have deleted my answer above as it was answering something different


and actually your request is interesting, as it would add great flexibility to the module

in a future version we will think how to make such a feature accessible to the end-user (non-developer)

You can do what you suggested like this ...

1. To retrieve the tag ids from the post array inside the module use:
Code:
<?php $module_id = '45'; $fieldname = 'fc_tag_ids_'.$module_id; $fc_tag_ids = JRequest::getVar($fieldname, false); if ($fc_tag_ids) { $fc_tag_ids = is_array($fc_tag_ids) ? $fc_tag_ids : array($fc_tag_ids); $tag_ids = $fc_tag_ids; } ?>

2. To create a form field element that contains the tags use:
Code:
<?php $query = 'SELECT id AS value, name AS text' . ' FROM #__flexicontent_tags' . ' WHERE published = 1' . ' ORDER BY name ASC, id ASC' ; $db->setQuery($query); $tags = $db->loadObjectList(); $attribs = ' multiple="multiple" '; $fcmodule_id = '45'; $fieldname = 'fc_tag_ids_'.$fcmodule_id; $element_id = $fieldname; $values = JRequest::getVar($fieldname, array()); $tags_field = JHTML::_('select.genericlist', $tags, $fieldname, $attribs, 'value', 'text', $values, $element_id); echo $tags_field ; ?>

Please use form field name fc_tag_ids, as i WILL ADD this to the module in next version, but note that i will probably make it:
$form_name = 'fc_tag_ids_'.$module_id;
or something this way you will be able to upgrade to a module that needs no changes

Regards


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.256 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline