Results 1 to 9 of 9
  1. #1
    Full Member jazzylee77's Avatar
    Join Date
    February 19th, 2005
    Posts
    199
    An idea for adding products to existing pages
    I have some sites where the following might work.

    Say you have a folder with urls like:
    www.mysite.com/shop/coach+purse
    www.mysite.com/shop/pink+sweater
    or
    www.mysite.com/shop/baseball-glove
    www.mysite.com/shop/kenmore-oven

    There are some usable search terms at the end of those type pages urls.

    I could add the variables like /?psps_search=coach+purse to all the urls and put a php search enabled shop in there somewhere. But why mess up such a nice url?

    I'm wondering if the shop php code could be modified to take the variable after matching a string like /shop/ instead of ?psps_search=

    Another nice change for this would be: If there is no search result, then display nothing. No "We found 0 products for" So pages with unusable url endings don't have that look of malfunctioning.

    But now that I think on it... the sites I had in mind use the end of url to provide the content. adding /?whatever.... doesn't break that, but /whatever/ sure would. Modrewrite gives me nightmares...

    Maybe a better option would be to use the existing function that adds that end of url. I can display that easily with <?php echo ht($tagToSearch)?> So I know I could at least create a link to a relevant shop page that way. But better to use that <?php echo ht($tagToSearch)?> to set the variable for popshops as well.
    Last edited by jazzylee77; January 22nd, 2009 at 07:41 PM.

  2. #2
    Member
    Join Date
    January 2nd, 2008
    Posts
    72
    It sounds like you know php. You don't have to dig into modrewrite. You can use php to parse off that last part of the url.

    Take one of your urls: www.mysite.com/shop/kenmore-oven

    Code:
    <?php
      $request = $_SERVER['REQUEST_URI'];
      $request = explode('/',$request);
      $_REQUEST['psps_search'] = str_replace("-", " ", $request[sizeOf($request)-1]);
    ?>
    You could parse off the 'kenmore-oven', replace the dash with a space and then set that as the $REQUEST['psps_search'] variable before it gets into the PopShops code. The PopShops php code would then just see it as a normal search and pull back 'kenmore oven' related products.

  3. #3
    Full Member jazzylee77's Avatar
    Join Date
    February 19th, 2005
    Posts
    199
    Thanks. I'm just learning php in bits and pieces. This is another piece I'll try to understand as I try it.

  4. #4
    Full Member jazzylee77's Avatar
    Join Date
    February 19th, 2005
    Posts
    199
    This is working great so far. I'm having trouble getting the 1st line ob_start code to enable the redirect in this encrypted script, but that's another story.



    Pagination is no good since it adds /?psps_page=2 to the end of the url and that gets thrown in as the search parameter.

    I've found with this I don't need the search boxes enabled. And if I did use them it causes the same problem as above adding /?psps_search=whatever that is preloaded as the search parameter.

    But still. I can pull some cool tricks with this now.

    If there was an option for search to match any instead of all words, that would help on sites that have wordy urls that return nothing.

  5. #5
    Full Member jazzylee77's Avatar
    Join Date
    February 19th, 2005
    Posts
    199
    Some sites have a .php extension and I need to remove that from the end.

    Tried this to remove the last 4 characters but didn't work.

    PHP Code:
    <?php   
    $request 
    $_SERVER['REQUEST_URI'];   
    $request explode('/',$request);   
    $request substr($request0, -4);   
    $_REQUEST['psps_search'] = str_replace("-"" "$request[sizeOf($request)-1]); ?>

  6. #6
    Full Member jazzylee77's Avatar
    Join Date
    February 19th, 2005
    Posts
    199
    Got this bit working now with some help. It takes what's after/ and removes the last 4 characters. (.php in my case) Just change that -4 to whatever if you are removing some other length. Works like a charm adding relevant products to a site. And I only had to make the change in one of my include files to do it.

    PHP Code:
    <?php 
    $request 
    $_SERVER['REQUEST_URI'];    
    $request strrchr($request,'/');
    $request substr($request1, -4);
    echo 
    $request;
    $_REQUEST['psps_search'] = str_replace("-"" "$request); ?>
    with this code I needed to drop the [sizeOf($request)-1] ...that returned just the first letter. Oh... I just had that echo $request; line in there while I was testing and trying to see what was going on. It can be removed.
    Last edited by jazzylee77; February 3rd, 2009 at 02:42 PM.

  7. #7
    Full Member jazzylee77's Avatar
    Join Date
    February 19th, 2005
    Posts
    199
    another refinement. This changes any non alphanumeric character in the search terms to a space. so urls ending red_boots or red-boots work. Change is in the last line. (but last line wrapped for some reason...only 3 lines between the <?PHP ?>)
    PHP Code:
    <?php
    $request 
    $_SERVER['REQUEST_URI'];
    $request explode('/',$request);
    $_REQUEST['psps_search'] = ereg_replace("[^A-Za-z0-9]"" "$request[sizeOf($request)-1]);
    ?>
    or for the one that also removes the extension characters
    PHP Code:
    <?php  
    $request 
    $_SERVER['REQUEST_URI'];     
    $request strrchr($request,'/'); 
    $request substr($request1, -4); 
    $_REQUEST['psps_search'] = ereg_replace("[^A-Za-z0-9]"" "$request); ?>
    Haven't tested the second one yet. But it should work.

  8. #8
    Newbie
    Join Date
    February 15th, 2009
    Posts
    2
    I love what you're doing. Do you put this into the page header?

  9. #9
    Full Member jazzylee77's Avatar
    Join Date
    February 19th, 2005
    Posts
    199
    I just put it ahead of the usual php code for a shop that has search enabled.

    Many scripts like storebuilders have ways built in to grab a category or product name. I've gone back to some of those and used that snippet to define $_REQUEST

  10. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. EPC Dropped after adding pages
    By Andy626 in forum eBay Partner Network
    Replies: 4
    Last Post: May 22nd, 2012, 01:11 AM
  2. Problem With Adding Products
    By jackson992 in forum PopShops
    Replies: 5
    Last Post: November 24th, 2007, 11:51 AM
  3. Possible to integrate AllPosters code into existing pages?
    By Azam in forum Cusimano.com Scripts
    Replies: 1
    Last Post: August 16th, 2006, 11:31 PM
  4. Adding New Pages
    By Justdoit in forum Search Engine Optimization
    Replies: 3
    Last Post: November 4th, 2004, 05:48 AM
  5. adding perl sub-routine to existing script
    By breeze in forum Programming / Datafeeds / Tools
    Replies: 1
    Last Post: July 3rd, 2002, 08:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •