Multiple formats for page loops on same page?

Questions and answers about ShopSite Custom Templates

Multiple formats for page loops on same page?

Postby Yachtsman » Wed Feb 23, 2011 6:12 pm

My custom template has page links in "#contentleft". That works fine. The format of the loop is at the top of the page in "[--DEFINE LINK_TO_PAGE--]".

In addition to that format, on some pages I would like to have the page links displayed say in "#contentmiddle" in a different format.
Both #contentleft and contentmiddle on the same page.

Can I do that?
Yachtsman
 
Posts: 24
Joined: Fri Dec 11, 2009 9:21 am
Location: washington

Re: Multiple formats for page loops on same page?

Postby Jim » Wed Feb 23, 2011 8:30 pm

Are they the same links? If they are you would do something like this (note: code not tested, just an idea of how it would be done)

in the [-- define page --] section of the template where you want the left links to appear
[-- VAR.Linktype left --]
whatever start table or div formatting you need
[-- Loop Links --]
whatever start table row or div formatting you need
[-- link --]
whatever end table row or div formatting you need
[-- end_loop links --]
whatever end table or div formatting you need


in the section of the template where you want the center links to appear
[-- VAR.Linktype center --]
whatever start table or div formatting you need
[-- Loop Links --]
whatever start table row or div formatting you need
[-- link --]
whatever end table row or div formatting you need
[-- end_loop links --]
whatever end table or div formatting you need


In the [-- DEFINE LINK_TO_PAGE --] section of the page template

[-- IF VAR.linktype left --]
start the output formatting the way you need it for your left section
<a href="[-- OUTPUT_DIRECTORY_URL --]/[-- Page.FileName --]"> [-- PAGE.Name --]</a>
end the output formatting the way you need it for your left section
[-- ELSE_IF VAR.Linktype center --]
start the output formatting the way you need it for your center section
<a href="[-- OUTPUT_DIRECTORY_URL --]/[-- Page.FileName --]"> [-- PAGE.Name --]</a>
end the output formatting the way you need it for your center section
[-- ELSE --]
output the link if it is not in the left or center section.
<a href="[-- OUTPUT_DIRECTORY_URL --]/[-- Page.FileName --]"> [-- PAGE.Name --]</a>
[-- END_IF --]

You can get much more elaborate by using custom fields to contain link placement info and
then use IF statements based on the custom field to place certain links in specific areas and
exclude them from other areas. I believe other posts in the forum describe how that is done.
You should also checkout the template help and cookbook at
http://shopsite.com/help/10.2/en-US/sc/pro/custom.template.spec-page.html
http://shopsite.com/help/10.2/en-US/sc/pro/custom.template.spec.html
There are links on those pages to examples of different ways to to page links and other template features.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Re: Multiple formats for page loops on same page?

Postby ShopSite Lauren » Thu Feb 24, 2011 11:56 am

You could do it simplier by creating 2 page templates. One page template which has your left link format, and your page template code. For this example, lets say this template is called "PageTemplate-Left." You can then create a second page template which ONLY has the DEFINE LINK_TO_PAGE section setup. This template will be called "PageTemplate-Middle." For the PageTemplate-Middle template, you do not need to assign this template to any pages, or even fill in the DEFINE PAGE section of this template. You only need to setup the DEFINE LINK_TO_PAGE section. You can then include the loop links feature twice in your template. Where you have the [-- LINK --] tag you would include the name of the template you would like to use.

Loop link feature for the links on the left:
[-- LOOP LINKS --]
[-- LINK PageTemplate-Left --]
[-- END_LOOP LINKS --]

Loop link feature for the links in the middle:
[-- LOOP LINKS --]
[-- LINK PageTemplate-Middle --]
[-- END_LOOP LINKS --]
- ShopSite Lauren
Contact me for help with any of your
custom ShopSite template questions.
ShopSite Lauren
 
Posts: 887
Joined: Fri Aug 11, 2006 1:35 pm
Location: Orem, UT


Return to Custom Template Questions

Who is online

Users browsing this forum: No registered users and 89 guests