• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 27 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Customizing your template based on the current page
PostPosted: Mon Mar 17, 2008 4:26 am 
Offline
New Member
New Member

Joined: Fri Feb 22, 2008 5:52 pm
Posts: 4
I changed my urls to pretty urls; however, when I use the search module, the standard pages work, but the news pages do not show the proper url.

It shows /news/5/53/.  It inserts news instead of the actual news url name.

My search results template is...
Code:
<h3>{$searchresultsfor} "{$phrase}"</h3>
{if $itemcount > 0}
   <ul>
   {foreach from=$results item=entry}
      <li>{$entry->title} - <a href="{$entry->url}">{$entry->urltxt}</a> ({$entry->weight}%)</li>
   {/foreach}
   </ul>

   <p>{$timetaken}: {$timetook}</p>
{else}
   <p><strong>{$noresultsfound}</strong></p>
{/if}


My htacess is

Code:
Options +FollowSymLinks
RewriteEngine on

# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]

# News
RewriteRule ^([A-Za-z0-9-]+)/([0-9]+)/([0-9]+)/?$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$2&cntnt01returnid=$3 [L]

# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]


Help.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Customizing your template based on the current page
PostPosted: Mon Mar 17, 2008 11:06 am 
Offline
Forum Members
Forum Members

Joined: Tue Dec 25, 2007 5:56 pm
Posts: 84
calguy1000 wrote:
I hope this helps people out, and if you have any questions or comments, I'd be happy to hear them.


It's quite nice and helpful, but the major problem is IMHO that you have to disable caching for ALL your pages that use CC/FEU-logic. Depending on your server, that may cause significant waiting periods on each page view.

Thomas


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Customizing your template based on the current page
PostPosted: Sat Mar 29, 2008 6:56 pm 
calguy1000 wrote:
As well, I can hide the search form, if the user is not logged in or the search form is not useful on specific pages.
For example:
Code:
      {if $customcontent_loggedin > 0 && !isset($hidesearch)}
         <div class="search">{search}</div><!-- end of search -->
      {/if}


I hope this helps people, particularly those who are just starting with CMSMS.  Or, ar just starting to do conditional logic in their templates.

FYI: The example here used the FrontEndUsers and CustomContent modules.


Calguy,

If the intent was to prevent visitors from searching unless they are logged in, is it not necessary to modify the search templates as well? It's possible for a knowledgeable visitor to create a URL that called your search module and type it in manually in the address bar.

To prevent that I am modifying the search results template to only display data if the user was logged in.

Leslie


Top
   
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Customizing your template based on the current page
PostPosted: Sat Mar 29, 2008 7:01 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 7924
Location: Fernie British Columbia, Canada
Yes, if you were worried about the security of your content you would have to do that.

But  if you're just worried about the way the site looks on certain pages, or for logged in users then you could use this logic.  Otherwise, you'd have to put logic into the search results template too.

_________________
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Customizing your template based on the current page
PostPosted: Fri Oct 10, 2008 11:11 am 
Offline
Forum Members
Forum Members

Joined: Tue Nov 20, 2007 3:42 pm
Posts: 23
Hi,

Is it possible to make conditional statements based on the alias of the parent page/section?

Code:
{if $page == 'pagename'}
 do something for pagename
{else $page =='anotherpage'}
 do something else for another similar page
{/if}


I understand how the above works but am looking for something that would look something like this I guess:
Code:
{if $parent == 'pagename'}
 do something for pagename
{else $parent =='anotherpage'}
 do something else for another similar page
{/if}


Perhaps there is another way to do this, any help much appreciated.

Thanks,

Adam


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Customizing your template based on the current page
PostPosted: Tue Dec 16, 2008 5:22 am 
Offline
Dev Team Member
Dev Team Member

Joined: Tue Nov 21, 2006 5:05 pm
Posts: 731
Location: OH, USA
AngelEyes wrote:
Hi,

Is it possible to make conditional statements based on the alias of the parent page/section?

Code:
{if $page == 'pagename'}
 do something for pagename
{else $page =='anotherpage'}
 do something else for another similar page
{/if}


I understand how the above works but am looking for something that would look something like this I guess:
Code:
{if $parent == 'pagename'}
 do something for pagename
{else $parent =='anotherpage'}
 do something else for another similar page
{/if}


Perhaps there is another way to do this, any help much appreciated.

Thanks,

Adam


This is an old post, but... this can be done using calguy1000's CG simple smarty module.  Install using the module manager and view the help screen to see how to grab a page parent.

For example, I use this often to get the page root:

{$cgsimple->get_root_alias()}

_________________
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Multiple User Groups, One Menu, and assuring private access
PostPosted: Thu Feb 11, 2010 12:01 am 
Offline
New Member
New Member

Joined: Wed Feb 10, 2010 11:55 pm
Posts: 2
I need to print different menus for different FEU groups :
Does this tip still up to date ??
is there a simpler way to do it using excludeprefix="" parametter ??

calguy1000 wrote:
Here it is..... the latest howto as to how I solved this problem.  Here's the scenario:

Two user groups, each requiring independant content
One menu in the template
Users can be a member of both groups

Requirements:
CMS Made Simple 1.0.5 or greater
CustomContent 1.4.4 or Greater
MenuManager 1.4 or Greater
FrontEndUsers (version shouldn't matter much)

Steps:
1.  In the metadata field of each of your private pages, add code similar to this: (change your group names as required)
Code:
{assign var='content_is_visible' value='0'}
{if $customcontent_loggedin > 0}
   {if isset($customcontent_memberof_group1)}
       {assign var='content_is_visible' value='1'}
   {/if}
{/if}


2.  Add this user defined tag, named:  groups_to_prefixes
Code:
$postfix = '_';
if( isset($params['postfix']) )
{
   $postfix = trim($params['postfix']);
}

$adjustcase =1;
if( isset($params['noadjustcase']) )
{
  $adjustcase = 0;
}

if( isset($params['groups']) )
{
   $groups = explode(',',$params['groups']);
   for( $i = 0; $i < count($groups); $i++ )
     {
          if( $groups[$i] != '' )
          {
              if( $adjustcase == 1 )
                 {
                     $groups[$i] = strtolower($groups[$i].$postfix);
                 }
              else
                 {
                     $groups[$i] = $groups[$i].$postfix;
                  }
           }
     }

   return implode(',',$groups);
}
return '';


3.  Adjust your menu call in your template like this:
Code:
         {assign var='includeprefix' value='public_'}
         {if $customcontent_loggedin > 0}
            {capture assign='includeprefix'}{$includeprefix},{groups_to_prefixes groups=$customcontent_groups}{/capture}
         {/if}
         {cms_module module='menumanager' template='andreas01 : andreasmenu'   collapse='1' number_of_levels='2' includeprefix=$includeprefix}


4.  Adjust your content area in your template like this:
Code:
       {if !isset($content_is_visible)}
            {* assume public content, unless the variable is already set *}
            {assign var='content_is_visible' value='1'}
        {/if}
        {if $content_is_visible == '1'}
           {content block='header'}
           {content}
        {else}
            <div class="bigerror">Private Content.  Authorization Required</div>
        {/if}


5. Adjust the page alias of all of your pages as follows:

     Pages that anonymous/non logged in people can see should start with public_
     Pages that only members of group1 can see should begin with group1_   (change group1 to your group name of course)
     Similarly, pages that only members of group2 can see should begin with group2_

Conclusion:
Now, the menu should appear properly for anonymous users as well as for members of group1 and/or group2.  Also, anybody directly accessing a page their not entitled to see, should get the 'Authorization Required' message.

This solution should work for any number of groups, with menu.  I hope this helps everybody.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Customizing your template based on the current page
PostPosted: Thu Feb 11, 2010 12:14 am 
Offline
Power Poster
Power Poster

Joined: Mon Jun 12, 2006 9:02 pm
Posts: 1900
check this document for more up-to-date info.  (document written by calguy1000)

http://calguy1000.com/uploads/1/Hiding_ ... e-pdf.html


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Customizing your template based on the current page
PostPosted: Thu Feb 11, 2010 5:44 am 
Offline
New Member
New Member

Joined: Wed Feb 10, 2010 11:55 pm
Posts: 2
I did it  :D Thanks a lot !
I spent time to read the full documentation but it is very interesting.
By the way, I tried the "old way" : it was a failure


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Customizing your template based on the current page
PostPosted: Thu Feb 11, 2010 7:53 am 
Offline
Forum Members
Forum Members

Joined: Sun Jan 10, 2010 10:59 am
Posts: 142
I followed this Tip and noticed that I was likely trapped  because of changes from earlier versions of CMSMS (CMS 1.0.5?) and has not been adjusted for the actual version (1.6.6).
In this TIP it is written to put a Smarty tag in the "metadata field" but that doesn't work (anymore?). It needs to be placed in the "Smarty data or logic..." area. It took me quite some time to figure that one out so I hope this will be helpful and time saving for others.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Newbie to CMSMS and need help please.
PostPosted: Thu Dec 16, 2010 7:23 pm 
Offline
New Member
New Member

Joined: Thu Dec 16, 2010 5:05 pm
Posts: 3
I am trying to create a members area on a website. I want the private page to show up on the menu when the user correctly logs in.

I meet all of these requirements below:

calguy1000 wrote:

Requirements:
CMS Made Simple 1.0.5 or greater
CustomContent 1.4.4 or Greater
MenuManager 1.4 or Greater
FrontEndUsers (version shouldn't matter much)


In this step I pasted this information into my private page's metadata field and changed this: {if isset($customcontent_memberof_group1)} to this: {if isset($customcontent_memberof_ambassadors}. Which is a group that I had already created and assigned a test user to.
Quote:
Steps:
1.  In the metadata field of each of your private pages, add code similar to this: (change your group names as required)
Code:
{assign var='content_is_visible' value='0'}
{if $customcontent_loggedin > 0}
   {if isset($customcontent_memberof_group1)}
       {assign var='content_is_visible' value='1'}
   {/if}
{/if}


I created a user defined tag with the code below and named it groups_to_prefixes
Quote:
2.  Add this user defined tag, named:  groups_to_prefixes
Code:
$postfix = '_';
if( isset($params['postfix']) )
{
   $postfix = trim($params['postfix']);
}

$adjustcase =1;
if( isset($params['noadjustcase']) )
{
  $adjustcase = 0;
}

if( isset($params['groups']) )
{
   $groups = explode(',',$params['groups']);
   for( $i = 0; $i < count($groups); $i++ )
     {
          if( $groups[$i] != '' )
          {
              if( $adjustcase == 1 )
                 {
                     $groups[$i] = strtolower($groups[$i].$postfix);
                 }
              else
                 {
                     $groups[$i] = $groups[$i].$postfix;
                  }
           }
     }

   return implode(',',$groups);
}
return '';



I placed the code below within my template where I want the menu to be. And I changed this: {cms_module module='menumanager' template='andreas01 : andreasmenu'  collapse='1' number_of_levels='2' includeprefix=$includeprefix} to this:  {cms_module module='menumanager' template='header_menu'  collapse='1' number_of_levels='2' includeprefix=$includeprefix} where header_menu is the name of my menu template.
Quote:

3.  Adjust your menu call in your template like this:
Code:
         {assign var='includeprefix' value='public_'}
         {if $customcontent_loggedin > 0}
            {capture assign='includeprefix'}{$includeprefix},{groups_to_prefixes groups=$customcontent_groups}{/capture}
         {/if}
         {cms_module module='menumanager' template='andreas01 : andreasmenu'   collapse='1' number_of_levels='2' includeprefix=$includeprefix}


I pasted the code blow into the content area of my templates and did not change anything.
Quote:
4.  Adjust your content area in your template like this:
Code:
       {if !isset($content_is_visible)}
            {* assume public content, unless the variable is already set *}
            {assign var='content_is_visible' value='1'}
        {/if}
        {if $content_is_visible == '1'}
           {content block='header'}
           {content}
        {else}
            <div class="bigerror">Private Content.  Authorization Required</div>
        {/if}



I added public_ to all of my public pages and ambassadors_ to my private page as stated below. Where again ambassadors is my group with the one test user I have created. The public pages show up in my menu and the private page is hidden from the menu when I am not logged in. However, when logged in the private page does not show up in my menu but the public pages still do.

Quote:
5. Adjust the page alias of all of your pages as follows:
     Pages that anonymous/non logged in people can see should start with public_
     Pages that only members of group1 can see should begin with group1_   (change group1 to your group name of course)
     Similarly, pages that only members of group2 can see should begin with group2_

Conclusion:
Now, the menu should appear properly for anonymous users as well as for members of group1 and/or group2.  Also, anybody directly accessing a page their not entitled to see, should get the 'Authorization Required' message.

This solution should work for any number of groups, with menu.  I hope this helps everybody.


Any help on this would be greatly appreciated. I think I have posted every thing I need to, if not please let me know and I will post it immediately. Thanks


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Newbie to CMSMS and need help please.
PostPosted: Thu Dec 16, 2010 7:51 pm 
Offline
Power Poster
Power Poster

Joined: Mon Jun 12, 2006 9:02 pm
Posts: 1900
garrick wrote:
I am trying to create a members area on a website. I want the private page to show up on the menu when the user correctly logs in.

I meet all of these requirements below:

calguy1000 wrote:

Requirements:
CMS Made Simple 1.0.5 or greater
CustomContent 1.4.4 or Greater
MenuManager 1.4 or Greater
FrontEndUsers (version shouldn't matter much)


In this step I pasted this information into my private page's metadata field and changed this: {if isset($customcontent_memberof_group1)} to this: {if isset($customcontent_memberof_ambassadors}. Which is a group that I had already created and assigned a test user to.
Quote:
Steps:
1.  In the metadata field of each of your private pages, add code similar to this: (change your group names as required)
Code:
{assign var='content_is_visible' value='0'}
{if $customcontent_loggedin > 0}
   {if isset($customcontent_memberof_group1)}
       {assign var='content_is_visible' value='1'}
   {/if}
{/if}


I created a user defined tag with the code below and named it groups_to_prefixes
Quote:
2.  Add this user defined tag, named:  groups_to_prefixes
Code:
$postfix = '_';
if( isset($params['postfix']) )
{
   $postfix = trim($params['postfix']);
}

$adjustcase =1;
if( isset($params['noadjustcase']) )
{
  $adjustcase = 0;
}

if( isset($params['groups']) )
{
   $groups = explode(',',$params['groups']);
   for( $i = 0; $i < count($groups); $i++ )
     {
          if( $groups[$i] != '' )
          {
              if( $adjustcase == 1 )
                 {
                     $groups[$i] = strtolower($groups[$i].$postfix);
                 }
              else
                 {
                     $groups[$i] = $groups[$i].$postfix;
                  }
           }
     }

   return implode(',',$groups);
}
return '';



I placed the code below within my template where I want the menu to be. And I changed this: {cms_module module='menumanager' template='andreas01 : andreasmenu'   collapse='1' number_of_levels='2' includeprefix=$includeprefix} to this:  {cms_module module='menumanager' template='header_menu'   collapse='1' number_of_levels='2' includeprefix=$includeprefix} where header_menu is the name of my menu template.
Quote:

3.  Adjust your menu call in your template like this:
Code:
         {assign var='includeprefix' value='public_'}
         {if $customcontent_loggedin > 0}
            {capture assign='includeprefix'}{$includeprefix},{groups_to_prefixes groups=$customcontent_groups}{/capture}
         {/if}
         {cms_module module='menumanager' template='andreas01 : andreasmenu'   collapse='1' number_of_levels='2' includeprefix=$includeprefix}


I pasted the code blow into the content area of my templates and did not change anything.
Quote:
4.  Adjust your content area in your template like this:
Code:
       {if !isset($content_is_visible)}
            {* assume public content, unless the variable is already set *}
            {assign var='content_is_visible' value='1'}
        {/if}
        {if $content_is_visible == '1'}
           {content block='header'}
           {content}
        {else}
            <div class="bigerror">Private Content.  Authorization Required</div>
        {/if}



I added public_ to all of my public pages and ambassadors_ to my private page as stated below. Where again ambassadors is my group with the one test user I have created. The public pages show up in my menu and the private page is hidden from the menu when I am not logged in. However, when logged in the private page does not show up in my menu but the public pages still do.

Quote:
5. Adjust the page alias of all of your pages as follows:
     Pages that anonymous/non logged in people can see should start with public_
     Pages that only members of group1 can see should begin with group1_   (change group1 to your group name of course)
     Similarly, pages that only members of group2 can see should begin with group2_

Conclusion:
Now, the menu should appear properly for anonymous users as well as for members of group1 and/or group2.  Also, anybody directly accessing a page their not entitled to see, should get the 'Authorization Required' message.

This solution should work for any number of groups, with menu.  I hope this helps everybody.


Any help on this would be greatly appreciated. I think I have posted every thing I need to, if not please let me know and I will post it immediately. Thanks

Don't have time to read your full post, but the first thing you need to do is to use the current syntax for CustomContent.  The post you quoted was from 2007, and a lot has changed since then.

This:
Quote:
{if $customcontent_loggedin > 0}
  {if isset($customcontent_memberof_group1)}


should be
Quote:
{if $cccuser->loggedin()}
  {if $ccuser->memberof('group1')}


This document would be worth your time:
http://calguy1000.com/uploads/1/Hiding_ ... e-pdf.html


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 27 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
A2 Hosting