Does anyone have a navigation menu for products on a page?

General ShopSite user discussion

Does anyone have a navigation menu for products on a page?

Postby Capt.Goodvibes » Fri Nov 17, 2006 2:48 pm

I am trying to generate a menu with a link to an anchor for each product. Each product has many subProducts. What I came up with requires that I
Code: Select all
[-- LOOP PRODUCTS --]
twice. Once at the top of the page to make the menu and once to add the products to the page.

If I try to loop the products like this...
Code: Select all
<!-- put a text menu -->
<table width="[-- PAGE.PageWidth --]" align="center">
  <tr>
    <td>[-- LOOP PRODUCTS --]
    [-- GENERATE_MESSAGE "making a text menu" PRODUCT.Name --]
    <a href="#[-- PRODUCT.Name --]">&nbsp;[-- PRODUCT.Name --]&nbsp;</a>
[-- END_LOOP PRODUCTS --]</td>
  </tr>
</table>
in an attempt to generate the menu, Shopsite complains that it reached
Code: Select all
[-- END_LOOP --]
without finding
Code: Select all
[-- PRODUCT --]
I suppose that I'm not allowed to run this loop twice? I can't believe I'm the first one to want this to work. Any ideas?
Capt.Goodvibes
 
Posts: 18
Joined: Fri Nov 10, 2006 5:36 pm

Postby Jim » Fri Nov 17, 2006 8:53 pm

You can have as many loop product sections in the template as you need but you have to follow the correct syntax.

Here is the basic for of a loop product section

[-- LOOP PRODUCTS --]
[-- PRODUCT --]
[-- END_LOOP PRODUCTS --]

The tag [-- PRODUCT --] will be replace by the code generate by the PRODUCT template not any code that is in the page template.

If you need the product to be formated in a different way in each Loop Product section then you can use the tag [-- PRODUCT template --]
Where the word "template" is replaced by the name of the template that is to be used. This will override the template that is assigned to the product on the Edit Product Layout screen.

Your product template has the code to layout how each individual product looks and should at a minimum look something like

[-- DEFINE PRODUCT --]
your html for laying out the product goes here like this
[-- GENERATE_MESSAGE "making a text menu" PRODUCT.Name --]
<a href="#[-- PRODUCT.RecordNumber --]">&nbsp;[-- PRODUCT.Name --]&nbsp;</a>
[-- END_DEFINE PRODUCT --]

Note: I replaced your #[--product.name--] with
[-- PRODUCT.RecordNumber --] so the link will go to the ShopSite provided anchor tag for each product.

You would create another Product template to define how your product would look in another spot on your page.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Postby Capt.Goodvibes » Mon Nov 27, 2006 2:32 pm

Ok that's almost working but I have an anchor sneaking into the text menu so all the links link to the menu ( SEE BELOW )

I've copied the bits of code that should be working to make the menu and add the anchors to the products...

Anything jump out at you?

Thanks


The hacker_product_menu template:
Code: Select all
<!-- text menu template -->
[-- DEFINE PRODUCT --]
[-- GENERATE_MESSAGE "making a text menu" PRODUCT.Name --]
<a href="#[-- PRODUCT.RecordNumber --]">&nbsp;[-- PRODUCT.Name --]&nbsp;</a>
[-- END_DEFINE PRODUCT --]



the line from the product template that is working correctly... I think...

Code: Select all
<a name="[-- PRODUCT.RecordNumber --]"></a><h2 style="color:#ffffff;Background-color:#0000ff;padding:5">[-- PRODUCT.Name --]</h2>


The Page Template:
Code: Select all
<!--*************************-->
<!-- Begin Table of Products -->
<!--*************************-->
<!-- loop the products using a template to put a text menu -->
<table width="[-- PAGE.PageWidth --]" align="center">
  <tr>
    <td>
      [-- LOOP PRODUCTS --]
        [-- PRODUCT hacker_product_menu --]
      [-- END_LOOP PRODUCTS --]
    </td>
  </tr>
</table>

<!-- loop the actual products -->
[-- VAR.border 0 --]
<table width="[-- PAGE.PageWidth --]" align="center" border="[-- VAR.border --]" cellpadding="3">
  [-- LOOP PRODUCTS PAGE.Columns --]
    <td valign="top" align="[-- VAR.align --]">&nbsp;<br>[-- PRODUCT --]</td>
  [-- END_LOOP PRODUCTS --]
</table>
<!-- End Table of Products -->





The webpage html source:
Code: Select all
<!-- oop the products using a template to put a text menu -->
<table width="75%" align="center">
  <tr>
    <td>    <!--- rec 197 -->
<a name="197"></a>
<a href="#197">&nbsp;Harley Touring&nbsp;</a>

    <!--- rec 198 -->
<a name="198"></a>
<a href="#198">&nbsp;Harley Softail&nbsp;</a>

    <!--- rec 199 -->

<a name="199"></a>
<a href="#199">&nbsp;Harley Sportster&nbsp;</a>

    <!--- rec 200 -->
<a name="200"></a>
<a href="#200">&nbsp;Harley Shovelhead&nbsp;</a>

</td>
  </tr>
</table>
Capt.Goodvibes
 
Posts: 18
Joined: Fri Nov 10, 2006 5:36 pm

Postby Capt.Goodvibes » Mon Nov 27, 2006 4:40 pm

The comment and anchor are being added without my control.

Here's my attempt at showing the location in the flow where the problem exists. I will indicate the menu template within the LOOP. Code and examples between the // comments does not exist in any of my templates

Code: Select all
<!-- this is in the page_template -->
[-- LOOP PRODUCTS --]
<!-- call the menu template -->
[-- PRODUCT hacker_product_menu --]

// nebulous area between templates where some system call or hidden template call is inserting this(example):
<!--- rec 200 -->
<a name="200"></a>
// note the 3 dashes in the comment

<!-- menu template doesn't start until here -->
[-- DEFINE PRODUCT --]
<a href="#[-- PRODUCT.RecordNumber --]">&nbsp;[-- PRODUCT.Name --]&nbsp;</a>
[-- END_DEFINE PRODUCT --]

<!--  back to the page template here -->
[-- END_LOOP PRODUCTS --]


I confirmed the flow by inserting a partial ( <!-- )comment before the [-- PRODUCT hacker_product_menu --] in the page template and tried to close it ( --> ) before [-- DEFINE PRODUCT --] in the menu template.

Please help.
Capt.Goodvibes
 
Posts: 18
Joined: Fri Nov 10, 2006 5:36 pm

Postby Jim » Mon Nov 27, 2006 5:01 pm

The anchor tag will always be output by ShopSite for each product so you will end up with that tag any place you do a loop products.

Although the accepted use is to only have 2 hyphens at the start of a comment after the ! it is not required. According to http://www.w3.org/TR/html4/intro/sgmltut.html
"Authors should avoid putting two or more adjacent hyphens inside comments."

Note the use of the word 'should' and not that it is a requirement.

I'll log it as an enhancement request to change it to just 2 but this should not cause any problems.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Postby Capt.Goodvibes » Mon Nov 27, 2006 5:08 pm

No, I was only pointing out the 3 dashes to try and find the spot that the anchor is being added.

So can you give me someadvice as to how to make a text menu dynamically?

Here's a page so you can see what I'm attempting.

http://www.hackerpipes.com/products/harley.php
Capt.Goodvibes
 
Posts: 18
Joined: Fri Nov 10, 2006 5:36 pm

Postby Capt.Goodvibes » Mon Nov 27, 2006 5:22 pm

I got it working. I overthunk it :)

I changed the anchor name to PRODUCT.Name

There won't be any duplicates so...
Capt.Goodvibes
 
Posts: 18
Joined: Fri Nov 10, 2006 5:36 pm


Return to User Forum

Who is online

Users browsing this forum: No registered users and 34 guests