[HowTo] Internal item switch to control item/field output

More
12 years 3 weeks ago #24594 by gruz
I have a type "Partnter" which has a web-link field.
In the same type I have a select field, which allows to select "Internal" or "External"
[img


I have another type "Project" where I chose related items of the "Parnter" type.
[img


At the "Project" page I output the web-link field via the universal module (to have more control over the output).

Depending on the state of the select list (Internal or External) I want to control the output either the link to the "Partner" page, or link to the partner's web-site.

My suggestion is to check the switch status in the template (module one, or item one) and to set the output I need. Is this the right approach? Is there any better way?

J2.5
FC - 2.0 - Rev 1612 (since 17-00 30.12.2012)

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

More
12 years 2 days ago #25200 by igcorreia
Hello, form what I know, and as already been requested to have connected fields, we are doing a complex site right now and we have the same problem and don't know how to solved this.

We want to provide different field depending on the user choice.

The solutions we found is via different TYPES of content and there you associate different fields to different types.

Because the only place in the submission form where the fields update is in the TYPE of content select. This way the user will have to make the decision very early in the form. Does this makes sense?

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

More
12 years 2 days ago #25202 by ggppdk
Lets take gruz EXAMPLE

You need a weblinks field and you want to make it use the value of a select field, so that it behaves/displays different things in item view AND-OR in item edit form TOO.

In this case you will need to
1. Duplicate weblinks field to a new field type e.g. tweblinks
2. Create a tweblinks field named twblnk
3. Create a select field named selwbtype
4. Alter tweblinks field XML parameters file to add a text parameter named "relselfield" where you will enter the name of the select field in our case it will be selwbtype
5. Alter functions onDisplayFieldValue() and onDisplayField() of tweblinks field to retrieve the value of the field named connected_selfield for the current item (current item is $item)
Code:
$db = &JFactory::getDBO(); $query='SELECT fv.value' .' FROM #__flexicontent_fields_item_relations AS fv' .' LEFT JOIN #__flexicontent_fields as f ON f.id=fv.field_id AND f.name="'.$params->get('relselfield').'"' .' WHERE fv.item_id='.$item->id; $db->setQuery($query); $rsvalue = $db->loadResult();
6. Use value $rsvalue to alter the behavior of the functions onDisplayFieldValue() (ITEM VIEW) and onDisplayField() (ITEM EDIT FORM)

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.587 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