Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Join Date
    Jun 2007
    Location
    Bronx, New York, United States
    Posts
    521
    Plugin Contributions
    3

    Default Mimicing $_GET['main_page']

    Anyone know how would I get started on trying to code an alternative lookup for products?

    What I was hoping on doing is changing ZenCart to not only look up a product page from this:
    http://www.example.com/index.php?main_page=product_cards_ufs_info&cPath=1_6&products_id=124

    To this as an alternative:
    http://www.example.com/index.php?ufs_card=SOME_ID

    So that it pulls up the product page of that SOME_ID (which is stored in a seperate database attached to a product ID number).

    I'm trying to find the look ups for $_GET['main_page'] but I'm running out of ideas.
    Last edited by retched; 18 Jul 2014 at 05:47 PM.

  2. #2
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Mimicing $_GET['main_page']

    I'm not sure I understand. Why do you need $_GET['main_page'] if your URL doesn't even reference main_page ?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Jun 2007
    Location
    Bronx, New York, United States
    Posts
    521
    Plugin Contributions
    3

    Default Re: Mimicing $_GET['main_page']

    I used $_GET['main_page'] as a point of reference really. But what I wanted to have happen is if ZenCart sees the browser is sending the top URL, act normally. But if it receives a URL like the second URL in my original post, instead search through a database for that something and redirect the user to that product information page.

    Another way of explaining it would be if I tried to reach a product info page using a UPC code or ISBN number instead. That's what the second link is supposed to be reminiscent of.

    I'm not sure if I explained it well in this case.

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

    Default Re: Mimicing $_GET['main_page']

    Quote Originally Posted by retched View Post
    I used $_GET['main_page'] as a point of reference really. But what I wanted to have happen is if ZenCart sees the browser is sending the top URL, act normally. But if it receives a URL like the second URL in my original post, instead search through a database for that something and redirect the user to that product information page.

    Another way of explaining it would be if I tried to reach a product info page using a UPC code or ISBN number instead. That's what the second link is supposed to be reminiscent of.

    I'm not sure if I explained it well in this case.
    So there is at least one uri rewriter that could do this for you, without redeveloping the wheel. One that comes to mind is CEON URI rewriter. Allows you to add whatever "text" you want to represent your product(s) and to redirect to that location as well it recognizes the default/standard ZC format. Don't know if it is compatible with 1.5.3 yet, as haven't tried it under that version.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Mimicing $_GET['main_page']

    Right, so if you're after so-called human-friendly-URLs, then the suggestion by mc12345678 is the best place to start.

    But if you're wanting to get into writing custom code for very specialized use, then probably adding something to extra_functions to do your work would be a good starting point.
    Then:
    - see if $_GET['ufs_card'] is set
    - if it is, then take its value and do whatever lookups are relevant, and then set $_GET['main_page'] and any other $_GET vars required to trick the site into doing what you requested (ie: rebuilding the URL by setting GET params)
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  6. #6
    Join Date
    Jun 2007
    Location
    Bronx, New York, United States
    Posts
    521
    Plugin Contributions
    3

    Default Re: Mimicing $_GET['main_page']

    Quote Originally Posted by DrByte View Post
    Right, so if you're after so-called human-friendly-URLs, then the suggestion by mc12345678 is the best place to start.

    But if you're wanting to get into writing custom code for very specialized use, then probably adding something to extra_functions to do your work would be a good starting point.
    Then:
    - see if $_GET['ufs_card'] is set
    - if it is, then take its value and do whatever lookups are relevant, and then set $_GET['main_page'] and any other $_GET vars required to trick the site into doing what you requested (ie: rebuilding the URL by setting GET params)
    This more or less points me in the right direction, I knew it was somewhere in extra_functions but didn't know the starting point. My only other question would be if there is an innate function in ZenCart that builds the URL (?main_page=index&......) or is this going to need to be built by me?

  7. #7
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Mimicing $_GET['main_page']

    Why are you building more URLs?

    The built-in function that generates href links won't know or understand anything about your custom URL parameters.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  8. #8
    Join Date
    Jun 2007
    Location
    Bronx, New York, United States
    Posts
    521
    Plugin Contributions
    3

    Default Re: Mimicing $_GET['main_page']

    No no. I meant for the redirection if it is safe for me to just redirect to a product info page using a URL like this:
    "/index.php?main_page=product_info&products_id=181"

    Without using any cPath info?

    Or if I have to build the cPath as well?

  9. #9
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Mimicing $_GET['main_page']

    You can do it without cPath, but that may cause SEO complications with canonical URLs.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  10. #10
    Join Date
    Jun 2007
    Location
    Bronx, New York, United States
    Posts
    521
    Plugin Contributions
    3

    Default Re: Mimicing $_GET['main_page']

    Quote Originally Posted by DrByte View Post
    You can do it without cPath, but that may cause SEO complications with canonical URLs.
    Okay so here's what I have so far:

    PHP Code:
        if(isset($_GET['ufs'])) {
            
    $ufs $_GET['ufs'];
            
    // First let's "fix" the search symbol.
            // Any sort of %20 and etc are already removed by PHP, so there is no need to run it a second time.
            // Let's remove any Underscores (as this will be a valid shortcut such as SPECIAL_X or DS01_20)
            
    $ufs strtoupper(str_replace("_"" "$ufs));

            
    $ufs_query "SELECT ufs.products_id, master_categories_id FROM " TABLE_CARDS_UFS " ufs LEFT JOIN " TABLE_PRODUCTS " p ON ufs.products_id = p.products_id WHERE collector_no = '" $ufs "' LIMIT 1";
            
    $ufs_get_result $db->Execute($ufs_query);

            
    $ufs_id $ufs_get_result->fields['products_id'];
            
    $category_id $ufs_get_result->fields['master_categories_id'];

            if(
    $ufs_id && $category_id) {
                
    // Okay we have a valid result... Let's do a redirect.
                
    zen_redirect(zen_href_link("product_cards_ufs_info"'cPath=' zen_get_generated_category_path_rev($category_id) . '&products_id=' $ufs_id'NONSSL'), 307);
            } else { 
    // We didn't find a valid result... so redirect them to page not found OR homepage.
                
    if (MISSING_PAGE_CHECK == 'On' || MISSING_PAGE_CHECK == 'true') {
                    
    zen_redirect(zen_href_link(FILENAME_DEFAULT));
                } else if (
    MISSING_PAGE_CHECK == 'Page Not Found') {
                    
    zen_redirect(zen_href_link(FILENAME_PAGE_NOT_FOUND));
                }
            }
        } 
    (Obviously TABLE_CARDS_UFS is defined in a separate define.)

    My problem right now is:
    PHP Code:
    zen_redirect(zen_href_link(FILENAME_PAGE_NOT_FOUND)); 
    I'm trying to use the redirect code 404 but for some reason when I use:
    PHP Code:
    zen_redirect(zen_href_link(FILENAME_PAGE_NOT_FOUND), 404); 
    I get a blank page. Any sugestions?

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Link issue - main_page=product_info / main_page=_info
    By Chrome Orange in forum General Questions
    Replies: 5
    Last Post: 7 May 2010, 05:34 AM
  2. Replies: 0
    Last Post: 12 Feb 2010, 07:10 PM

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