Show modules in Sidebar depending on content ID or alias
Show modules in Sidebar depending on content ID or alias
Hi, I wonder if it was possible to show modules in Sidebar depending on content's ID or alias? It would be really nice, and I am sure it would follow the concept of FEU smarty coding, but I am not that sure or experienced.
Thanks for your help in advance!
Thanks for your help in advance!
Re: Show modules in Sidebar depending on content ID or alias
this would have nothing to do with FrontEndUsers, BTW.
to expand on Dr.CSS's post...
something like
{if $page_alias == 'homepage'}
{news}
{elseif $page_alias == 'page2'}
{Uploads}
{elseif $page_alias == 'login'}
{FrontEndUsers}
{/if}
to expand on Dr.CSS's post...
something like
{if $page_alias == 'homepage'}
{news}
{elseif $page_alias == 'page2'}
{Uploads}
{elseif $page_alias == 'login'}
{FrontEndUsers}
{/if}
Re: Show modules in Sidebar depending on content ID or alias
Thanks.
May I follow up a bit. Can one filter for pages that do have content other than public, like for registered users (feu) and their groups?
May I follow up a bit. Can one filter for pages that do have content other than public, like for registered users (feu) and their groups?
Re: Show modules in Sidebar depending on content ID or alias
off the top of my head, an easy way would be to use the additional page attributes
(I can't remember the exact syntax for those attributes, but it would be something like this)
{if $extra1 == 'public'}
{news}
{elseif $extra1 == 'private'}
{Uploads}
{elseif $extra1 == ''}
{FrontEndUsers}
{/if}
You would simply add the appropriate keyword into the Extra 1 attribute field when creating the page. If the page has only public content, add 'public' to the Extra1. If the page has private content (protected by FEU/CC), add 'private'. Etc...
This would allow for quick and simple implementations, but would not work for more complex logic. There are probably several other ways to accomplish the same thing...
(I can't remember the exact syntax for those attributes, but it would be something like this)
{if $extra1 == 'public'}
{news}
{elseif $extra1 == 'private'}
{Uploads}
{elseif $extra1 == ''}
{FrontEndUsers}
{/if}
You would simply add the appropriate keyword into the Extra 1 attribute field when creating the page. If the page has only public content, add 'public' to the Extra1. If the page has private content (protected by FEU/CC), add 'private'. Etc...
This would allow for quick and simple implementations, but would not work for more complex logic. There are probably several other ways to accomplish the same thing...
Re: Show modules in Sidebar depending on content ID or alias
Any hints as to where can I find out the proper format of the commands your were giving?
The you were giving did not work.
I tried printing out the content of $extra1 using this
It did not worked either, because the result was "1" irrespective if I printed out $extra1, $extra2, etc ($extra1 was assigned to "r" in the admin panel of the page). I am not certain if the print command is proper either.
Are we talking here Smarty formalism or PHP?
Do you have a suggestion to filter for a News Items of a given Category?
Thanks again.
The you were giving did not work.
I tried printing out the content of $extra1 using this
Code: Select all
{$extra1|print_r}
Are we talking here Smarty formalism or PHP?
Do you have a suggestion to filter for a News Items of a given Category?
Thanks again.
Last edited by docman on Thu Jan 07, 2010 6:24 pm, edited 1 time in total.
Re: Show modules in Sidebar depending on content ID or alias
For content extra field try
P.S. don't forget to use "{get_template_vats}" first.
Code: Select all
{if $content_obj->GetPropertyValue('extra1')=='public'}
public content
{elseif $content_obj->GetPropertyValue('extra1')=='private'}
private content
{else}
default content
{/if}
Re: Show modules in Sidebar depending on content ID or alias
This is that youe meant saying "use {get_template_vars} first"?
This will include a large table with the template variable in the output. Incidentally, I looked for "$extra1" but could not find. I also printed out the content of $content_obj using {$content_obj|print_r}. I did find the label "extra1" but could not verify its content.
Hence my questions:
1. does $extra1 hold the value that I assude it does?
2. is this value being passed to the output template of the search module where I am testing this filtering you suggest?
Let me summarize and a bit rephrase my aim:
1. I use FEUs.
2. I created some restricted content for them in TWO places
- in Content Pages inserted into content blocks for Registered Users
- in News items into a category 'Restricted'
3. Now, when I use Search without any filtering in its Output Template, a search term containing some text that could also be found in these restricted content would result in listing those contents, that I obviously want to avoid
4. Hence the need for filtering by code (smarty) placed into the output template
5. One way of achieving this - as you suggested - is by using an Extra Page Attribute
6. One thus have to filter on the content of this Extra Page Attribute in a two-teared manner
- once for the registered content
- once for the news item in the 'Restricted' category
7. Obviously, using Extra Page Attributes would only work for the restricted content but not for the news item.
Unfortunately, filtering on Extra1 has not succeeded (see above).
Thank you for your continuing help.
Code: Select all
{get_template_vars}
{if $content_obj->GetPropertyValue('extra1')=='public'}
public content
{elseif $content_obj->GetPropertyValue('extra1')=='private'}
private content
{else}
{/if}
Hence my questions:
1. does $extra1 hold the value that I assude it does?
2. is this value being passed to the output template of the search module where I am testing this filtering you suggest?
Let me summarize and a bit rephrase my aim:
1. I use FEUs.
2. I created some restricted content for them in TWO places
- in Content Pages inserted into content blocks for Registered Users
- in News items into a category 'Restricted'
3. Now, when I use Search without any filtering in its Output Template, a search term containing some text that could also be found in these restricted content would result in listing those contents, that I obviously want to avoid
4. Hence the need for filtering by code (smarty) placed into the output template
5. One way of achieving this - as you suggested - is by using an Extra Page Attribute
6. One thus have to filter on the content of this Extra Page Attribute in a two-teared manner
- once for the registered content
- once for the news item in the 'Restricted' category
7. Obviously, using Extra Page Attributes would only work for the restricted content but not for the news item.
Unfortunately, filtering on Extra1 has not succeeded (see above).
Thank you for your continuing help.
Last edited by docman on Thu Jan 07, 2010 10:01 pm, edited 1 time in total.
Re: Show modules in Sidebar depending on content ID or alias
Variable "extra1" does not exist in your template. That is the point - to look for valid template variables first.I looked for "$extra1" but could not find.
Search module have parameter
Lets use itpassthru_*="null" - Pass named parameters down to specified modules. The format of each of these parameters is: "passtru_MODULENAME_PARAMNAME='value'" i.e.: passthru_News_detailpage='newsdetails'"
Code: Select all
{search passthru_News_category='restricted*'}
Code: Select all
object(stdClass)#456 (7) {
["url"]=> string(117) "http://www...."
["urltxt"]=> string(26) "Title..."
["title"]=> string(9) "News..."
["intweight"]=> int(3)
["module"]=> string(4) "News"
["modulerecord"]=> string(3) "300"
["weight"]=> int(100)
}
In general template variables are retained if "page_id" is the same as "returnid" in URL.is this value being passed to the output template of the search module where I am testing this filtering you suggest?
Re: Show modules in Sidebar depending on content ID or alias
Please find my followup questions embedded into your post!
Thanks a lot!
docman: thanks, this is that I suspected.
Search module have parameter
- where should this command go? I have two templates: one is that I would call the "main", the other is the "result template of the search module". The seconds one may just be inserted into the main one as soon as the {search} tag is executed, but I really do not know for sure.
Lets use it
docman:
- what would be the command to pass the value of extra1? Something like this?
docman:
- again, where would the following code of yours be inserted?
Structure of one search result looks like this
Pay attention to properties "weight" and "intweight". IMO record with "wheight"==100 meets all search conditions (search string, News category, ...). You can not to show some records from news module with low weight.
- I am afraid I do not understand the following. Could you elaborate on it a bit?
[/quote]In general template variables are retained if "page_id" is the same as "returnid" in URL.
Thanks a lot!
Variable "extra1" does not exist in your template. That is the point - to look for valid template variables first.I looked for "$extra1" but could not find.
docman: thanks, this is that I suspected.
Search module have parameter
docman:passthru_*="null" - Pass named parameters down to specified modules. The format of each of these parameters is: "passtru_MODULENAME_PARAMNAME='value'" i.e.: passthru_News_detailpage='newsdetails'"
- where should this command go? I have two templates: one is that I would call the "main", the other is the "result template of the search module". The seconds one may just be inserted into the main one as soon as the {search} tag is executed, but I really do not know for sure.
Lets use it
Code: Select all
{search passthru_News_category='restricted*'}
- what would be the command to pass the value of extra1? Something like this?
Code: Select all
{search passthru_exra1='restricted*'}
- again, where would the following code of yours be inserted?
Structure of one search result looks like this
Code: Select all
object(stdClass)#456 (7) {
["url"]=> string(117) "http://www...."
["urltxt"]=> string(26) "Title..."
["title"]=> string(9) "News..."
["intweight"]=> int(3)
["module"]=> string(4) "News"
["modulerecord"]=> string(3) "300"
["weight"]=> int(100)
}
docman:is this value being passed to the output template of the search module where I am testing this filtering you suggest?
- I am afraid I do not understand the following. Could you elaborate on it a bit?
[/quote]In general template variables are retained if "page_id" is the same as "returnid" in URL.
Last edited by docman on Fri Jan 08, 2010 2:29 pm, edited 1 time in total.
Re: Show modules in Sidebar depending on content ID or alias
Basic steps to filter out restricted news are:
1. In news extra field mark restricted record
2. Set summary template not to show restricted articles
3. Also hide content of restricted articles in detail template
4. (optional) When calling search module also pass name of news summary template to search results
a. There is no need to specify template if it is default one. Also you can skip it if you will specify it on step "5"
5. Use UDT to call articles by articleid in summary mode (by default article id is valid in detail mode only)
EDIT: parameter "ids" comma separated list of news article ids.
1. In news extra field mark restricted record
2. Set summary template not to show restricted articles
Code: Select all
{if empty($entry->extra)||($ccuser->loggedin()&&$ccuser->memberof($entry->extra))}
show summary
{/if}
4. (optional) When calling search module also pass name of news summary template to search results
Code: Select all
{search passthru_News_summarytemplate='summary_template'}
5. Use UDT to call articles by articleid in summary mode (by default article id is valid in detail mode only)
EDIT: parameter "ids" comma separated list of news article ids.
Code: Select all
{if $entry->module=='News'}
{news_ids ids=$entry->modulerecord summarytemplate='template_filter'}
{/if}
- Attachments
-
[The extension txt has been deactivated and can no longer be displayed.]
Last edited by Peciura on Sat Feb 27, 2010 4:38 pm, edited 1 time in total.
Re: Show modules in Sidebar depending on content ID or alias
Thanks for your reply. Please specify where the code segments you suggest would have toi be inserted. I am aware of two possible sites such as my "main" template and the summary template of the News module.
Thanks a lot.
Thanks a lot.
Re: Show modules in Sidebar depending on content ID or alias
step 2 goes to news summary template (created specially for search results, titlelinks only)Please specify where the code segments you suggest would have toi be inserted
step 3 - news detail templates (you want to be sure content visible to authorized vistors)
step 4 - test page first, later to main page template
step 5 - search result template
Re: Show modules in Sidebar depending on content ID or alias
Thanks. I have to admit, it is still not working. Certainly, because I am haviong gaps in terms of the formalism and concepts used in your code.Peciura wrote:step 2 goes to news summary template (created specially for search results, titlelinks only)Please specify where the code segments you suggest would have toi be inserted
step 3 - news detail templates (you want to be sure content visible to authorized vistors)
step 4 - test page first, later to main page template
step 5 - search result template
Hence, my questions:
Is my interpretation of this code proper?
Code: Select all
{if empty($entry->extra)||($ccuser->loggedin()&&$ccuser->memberof($entry->extra))}
show summary
{/if}
- THEN show news using the summary template
My questions:
1. I wanted to verify if extra has the value in the summary template that I assigned to it in the news item page ("restricted"). Hence in the above code (for step2) I inserted "{$extra|print_r} to print its value. Its value is always "1".
2. I am uncertain if the value of extra is passed on from the news item page to the summary or for that matter the detailed templates. What is the rule and code that applies to transferring values of parameters?
3. If this is the code for checking on the status of the user being logged in
"{if $ccuser->loggedin()} ...{/if}
what would be the conditional testing for a user being NOT logged in?
4. Is this construct correct?
Code: Select all
{if $entry->module=='News' category!='Private'}
...
{/if}
5. Where can I learn more on the followings with a focus on their implementation in CMSMS?
- passing parameters values in between templates
- passing parameters values in between content extra1, etc., and templates
- passing parameters values in between news extra and templates
- conditional testing on page attributes
- definitions of CMSMS tags
Many thanks for your help.
Last edited by docman on Tue Jan 12, 2010 9:25 pm, edited 1 time in total.
Re: Show modules in Sidebar depending on content ID or alias
Yes.Is my interpretation of this code proper?
Code:
{if empty($entry->extra)||($ccuser->loggedin()&&$ccuser->memberof($entry->extra))}
show summary
{/if}
- if updated content of $entry is NULL (that is extra is empty in the news item) OR if user is logged in AND he/she is member of group as specified in extra
- THEN show news using the summary template
a. If you simply want to restrict article in step 2 change to simple one1. I wanted to verify if extra has the value in the summary template that I assigned to it in the news item page ("restricted"). Hence in the above code (for step2) I inserted "{$extra|print_r} to print its value. Its value is always "1".
Code: Select all
{if empty($entry->extra)||($ccuser->loggedin()&&$entry->extra=='restricted'))}
show summary
{/if}
Code: Select all
{$entry|print_r}
Value of extra field is passed to summary.2. I am uncertain if the value of extra is passed on from the news item page to the summary or for that matter the detailed templates. What is the rule and code that applies to transferring values of parameters?
{var_dump var=$entry} output is
Code: Select all
object(stdClass)#441 (23) {
["author_id"]=>
string(1) "1"
["author"]=>
string(7) "admin"
["authorname"]=>
string(17) "..."
["id"]=>
string(3) "359"
["title"]=>
string(40) "Blah"
["content"]=>
string(2139) "..."
["summary"]=>
string(692) "..."
["postdate"]=>
string(19) "2009-10-16 13:45:54"
["extra"]=>
string(2) "53"
["startdate"]=>
string(19) "2009-10-16 13:45:54"
["enddate"]=>
NULL
["create_date"]=>
string(19) "2009-10-16 13:56:05"
["modified_date"]=>
string(19) "2009-12-19 00:44:08"
["category"]=>
string(23) "..."
["fieldsbyname"]=>
array(0) {
}
["fields"]=>
array(0) {
}
["file_location"]=>
string(43) "http://www.test..../uploads/news/id359"
["link"]=>
string(167) "http://www.test..."
["titlelink"]=>
string(222) "BLAH"
["morelink"]=>
string(189) "More"
["moreurl"]=>
string(167) "http://www.test..."
["printlink"]=>
string(199) "Print"
["printurl"]=>
string(174) "http://www.test..."
}
3. If this is the code for checking on the status of the user being logged in
"{if $ccuser->loggedin()} ...{/if}
Code: Select all
{if !$ccuser->loggedin()} ...{/if}
Code: Select all
{if empty($ccuser->loggedin())} ...{/if}
a. You missed logical "AND". Should be4. Is this construct correct?
Code:
{if $entry->module=='News' category!='Private'}
...
{/if}
For me it did not work. The idea to use it in the search results template would be to check if the item is coming from the News module and if its category is not Private; then the result could be displayed. Is the values of category passed to the search template?
Code: Select all
{if $entry->module=='News'&&category!='Private'}
...
{/if}
Structure of one search result looks like this
Code:
object(stdClass)#456 (7) {
["url"]=> string(117) "http://www...."
["urltxt"]=> string(26) "Title..."
["title"]=> string(9) "News..."
["intweight"]=> int(3)
["module"]=> string(4) "News"
["modulerecord"]=> string(3) "300"
["weight"]=> int(100)
}
5. Where can I learn more on the followings with a focus on their implementation in CMSMS?
I usually use global php variables $_GET, $_POST, $_COOKIE . Smarty can access them to ({$smarty} reserved variable) http://www.smarty.net/manual/en/language.variables.smarty.phppassing parameters values in between templates
a. I recommend reading all blog http://calguy1000.com/blog.html, you can start with http://calguy1000.com/Blogs/4/60/the-we ... dness.html- passing parameters values in between content extra1, etc., and templates
- passing parameters values in between news extra and templates
- conditional testing on page attributes
- definitions of CMSMS tags
b. Smarty page http://www.smarty.net/manual/en/
start with "Variable Modifiers", "Built-in Functions".
c. Extensions » Tags

d. Read my post about relationship between php functions and smarty variable modifiers http://forum.cmsmadesimple.org/index.ph ... #msg190202
No probs.