Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    red flag Do stuff on product id

    I am trying to generate HTML for something in the head section on product information pages only.

    So what would be the correct way to write something like this?

    PHP Code:

    if ($current_page_base == 'index' and $cPath == '1' and $products_id == '123') {
      echo 
    'DO STUFF';

    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  2. #2
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    Default Re: Do stuff on product id

    I've tried a few different variations, no success though. Thought something like this might work.

    PHP Code:

    if ($current_page_base == 'product_info' and $products_id == '123') {  echo 'DO STUFF';} 
    what I am trying to is output an AMP Page URL for product information pages. I can do this on categories by doing this.

    PHP Code:
    if ($current_page_base == 'index' and $cPath == 'YOUR_CATEGORY_ID') {  echo '<link rel="amphtml" type="text/css" href="https://yoururl.com/your-category-name-or-url">';} 
    But can't see how I would do similar for a product information page. I need to be able to specify the exact product information page id in a similar way to $cPath == 'YOUR_CATEGORY_ID'
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  3. #3
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,686
    Plugin Contributions
    123

    Default Re: Do stuff on product id

    I suspect $products_id is not set at the point you are injecting your code. Try using $_GET['products_id'].
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  4. #4
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Do stuff on product id

    And if your product has attributes, would recommend casting the $_GET['products_id'] to an integer otherwise when clicking on a product link in the shopping cart the "message" will not be displayed.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    red flag Re: Do stuff on product id

    ok this worked

    PHP Code:
    if ($current_page_base == 'product_info' and $_GET['products_id'] == '123') {  echo '<link rel="amphtml" type="text/css" href="https://MYDOMAINNAME.com/my-url-1.html">';} 
    if (
    $current_page_base == 'product_info' and $_GET['products_id'] == '234') {  echo '<link rel="amphtml" type="text/css" href="https://MYDOMAINNAME.com/my-url-2.html">';} 
    You would keep repeating the entries in tpl_main_page.php and where it reads $_GET['products_id'] == '234') - enter your product id.

    HTML Code:
    <link rel="amphtml" type="text/css" href="https://MYDOMAINNAME.com/my-url-2.html">
    - would be the link to your AMP page


    Thanks for the help guys, if you have anything else to add to this please let me know
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  6. #6
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Do stuff on product id

    To make your page(s) more flexible for relocation, would suggest that the destination links be made more generic so that one doesn't have to update the domain name or the connection method. If the page is located in the root of the catalog then need only to have the href="my-url-2.html" as an example.
    If it is at the root of the domain (where the catalog is found in a sub-folder), then thought should be able to use href="/my-url-2.html".
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    Default Re: Do stuff on product id

    Quote Originally Posted by mc12345678 View Post
    To make your page(s) more flexible for relocation, would suggest that the destination links be made more generic so that one doesn't have to update the domain name or the connection method. If the page is located in the root of the catalog then need only to have the href="my-url-2.html" as an example.
    If it is at the root of the domain (where the catalog is found in a sub-folder), then thought should be able to use href="/my-url-2.html".
    OK yes I get your point and thanks for that. I will look into it. There are some pages that can't go in the root as there are already lightweight HTML landing pages with similar names. But I think the product pages could go there.
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  8. #8
    Join Date
    Jan 2004
    Location
    N of San Antonio TX
    Posts
    9,145
    Plugin Contributions
    11

    Default Re: Do stuff on product id

    Excellent info on relative links at https://www.w3schools.com/html/html_filepaths.asp

  9. #9
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    Default Re: Do stuff on product id

    Quote Originally Posted by dbltoe View Post
    Excellent info on relative links at https://www.w3schools.com/html/html_filepaths.asp
    Yeah I know all that but I am just not sure if it works the same for AMP pages as they appear to recommend the full URL including the domain name. I suppose the only way to find out though is try it.
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  10. #10
    Join Date
    Jan 2004
    Location
    N of San Antonio TX
    Posts
    9,145
    Plugin Contributions
    11

    Default Re: Do stuff on product id

    Starting in 2016 and continuing through 2018, they say use https://... At least that won't cause the mixed content warning on a site.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Help with category menu and product stuff
    By JDuval in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 21 Feb 2011, 11:08 AM
  2. Missing Stuff
    By Darkjackwolf in forum General Questions
    Replies: 0
    Last Post: 10 Jun 2010, 03:13 AM
  3. Should I delete some stuff? & where to DL product list?
    By dudemaaan in forum Setting Up Categories, Products, Attributes
    Replies: 5
    Last Post: 2 Feb 2010, 07:47 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR