HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Looking For Some Tempcode

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#38472 (In Topic #8655)
Joe
Avatar

Honoured member

I'm trying to implement an 'Adminzone' link on a tab, only visible to a certain group. Is there a Tempcode symbol I can use to check if the user is in that group, and if not, it won't be displayed?

e.g.

Code

{+START,{$IF_IN_GROUP,1}<a href="site.com/adminzone">Adminzone</a>{+END}

Back to the top
 
Posted
Rating:
#38473
Joe
Avatar

Honoured member

I may not of closed that symbol the way I'm supposed to; just using it as an example. :P

Back to the top
 
Posted
Rating:
#38474
Joe
Avatar

Honoured member

Disregard this topic - this code seems to do the job:

Code

{+START,IF,{$IS_IN_GROUP,1,2}}blah{+END}

Back to the top
 
Posted
Rating:
#38557
Joe
Avatar

Honoured member

Now I'm try to display a logout link if the user is logged in, or a login link if the user is a guest. This doesn't seem to work:

Code

{+START,IF,{$IS_A_COOKIE_LOGIN,_true}}LOGOUT link{+END}

{+START,IF,{$IS_A_COOKIE_LOGIN,_false}}LOGIN link{+END}

I could just use some IF_IN_GROUP symbols, but I have a lot of member-groups, so going with that method would leave the template few messy. How can I accomplish this? :/

Back to the top
 
Posted
Rating:
#38560
Avatar

I think this'd work…

Code

{+START,IF,{$NOT,{$IS_GUEST}}}LOGOUT link{+END}

{+START,IF,{$IS_GUEST}}LOGIN link{+END}


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#38575
Avatar

Community saint

Thanks Joe.
Thanks Chris.

Works like a charm. Terrific!

 :thumbs:

Take my advice. I'm not using it!

View my working ocPortal site (version 9.x.x) at Anglo-Indian Portal
Back to the top
 
Posted
Rating:
#38656
Joe
Avatar

Honoured member

I'm trying to display a link to users who don't have access to the adminzone, but DO have access to the CMS. This works, I just want to make sure this is the way you'd do it. If not, how could I go about doing this properly?

Code

{+START,IF,{$NOT,{$HAS_ZONE_ACCESS,adminzone}}}{+START,IF,{$HAS_ZONE_ACCESS,cms}}
            <li><a href="{$BASE_URL}/cms/index.php"><span>CMS</span></a></li>
         {+END}{+END}

Back to the top
 
Posted
Rating:
#38675
Avatar

Yeah, that's good.

A slightly shorter way to write it would be:

Code

{+START,IF,{$AND,{$NOT,{$HAS_ZONE_ACCESS,adminzone}},{$HAS_ZONE_ACCESS,cms}}
            <li><a href="{$BASE_URL}/cms/index.php"><span>CMS</span></a></li>
         {+END}


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#38679
Joe
Avatar

Honoured member

Thanks. :D

Back to the top
 
Posted
Rating:
#39090
Joe
Avatar

Honoured member

How about this? Seems like it would be fairly easy…

Basically I want to create a new Comcode page. This page will only contain a version number (e.g. '1.7'). I want to add some things to other pages, but only display these things if the version on the version page matches the version I specify.

For example:

Comcode page: 'current_version.txt'

Code

1.7

Comcode page: 'blah.txt'

Code

Hello, and welcome blah blah blah!
{+START,{$INCLUDE_PAGE,current_version}{IF,{$PAGE_CONTENTS,1.7}}}some_text{+END}

The above is just an example, it obviously wouldn't work… :P

So basically, you'll only see some_text if the contents of the current_version Comcode page equaled '1.7'.

Back to the top
 
Posted
Rating:
#39091
Avatar

This'd probably work, but I'd suggest instead that you use OcCLE instead of a Comcode page.

Code

:set_value('my_version','1.7');

Code

Hello, and welcome blah blah blah!
{+START,IF,{$EQ,{$VALUE_OPTION,my_version},1.7}}some_text{+END}

Instead of 'EQ' you could use 'GT' (greater than) or 'LT' (less than) if you want to make an inequality.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: