Page 1 of 1

Global Content Blocks and Links

Posted: Mon Sep 24, 2007 7:50 pm
by versatility
I have a site where I am making extensive use of GCBs.  The site is essentially split into five areas for five different audiences, but some of the core information gets repeated.

I created all the repeating information in global content blocks which has been great, but I have run into one problem.  When a global content block contains a link, let's say to a contact page, how do I deal with that?  I would like to do something context sensitive, so if they are in the teachers section, they see a global contact block that has a link to the contact page, that link appears to also be in the teachers section as opposed to the main site or the student section.

In a non CMS scenario, I would have used a basic include with a relative link, but I am not quite getting that same result with the global content blocks, the CMS Self Links appear to me to need to be directed at an actual page.

Thanks much.

Re: Global Content Blocks and Links

Posted: Mon Sep 24, 2007 8:08 pm
by calguy1000
scenario 1.... you have a different template for each 'section'
  answer:  a) in the page template (very close to the top) add {assign var='section' value='teachers'}
                b) create a new contact page for each section, with the alias prefixed by the 'section' their in:
                    i.e:  teachers_contact, students_contact, etc.
                c) in the gcb that you want to do the logic
                      {capture assign='contactpage'}{$section}_contact{/capture}
                      {cms_selflink href="$contactpage}

scenario 2.... You're using the same template for all pages
  answer:  Same as above, except step 1.  you'll need to put the {assign var='section' value='teachers'} (or whatever) into
              the metadata section of each page.

Re: Global Content Blocks and Links

Posted: Mon Sep 24, 2007 8:15 pm
by versatility
Thank you very much, I will be trying it out!

Re: Global Content Blocks and Links

Posted: Mon Sep 24, 2007 9:38 pm
by versatility
I got this to work - the only hitch is that I had to wrap the cms selflink tag in actual to get it to be link and not text.  Does that seem correct?  This would be a much sleeker solution if I didn't have to edit each of those.

Re: Global Content Blocks and Links

Posted: Mon Sep 24, 2007 9:47 pm
by calguy1000
depends on how you were using cms_selflink.
if using it as {cms_selflink href='page_alias'} it only generates a URL.  it's in the docs.

Re: Global Content Blocks and Links

Posted: Mon Sep 24, 2007 10:28 pm
by versatility
if using it as {cms_selflink href='page_alias'} it only generates a URL.  it's in the docs.
I have read the docs, that is where I got the idea to wrap it in the tags to make a link.  I use the self links all the time, what I am asking is when I use the code you laid out, it appears as text and not a link.  In order to make it link I had to wrap href tags around it in html editor.

Re: Global Content Blocks and Links

Posted: Mon Sep 24, 2007 10:38 pm
by calguy1000
when using {cms_selflink href="blah"}, it generates a URL.  To use it, you'd do something like:
whatever blah text blah I wanted blah in the blah link blah