View Full Version : Easiest Way to Produce Page of Keyphrase Results
Hi All
I want to create some longtail pages based on keyphrases. I want to populate each page full of results from the ShopWindow feeds.
What's the easiest way to achieve this goal? I guess I could try hacking the ShopWindow Client software or I could just try starting from scratch with the API.
I want a separate .php file for each page that I can set meta tags for, title, description etc, then display product results based on a keyphrase.
Any thoughts anyone, or just a pointer on where best to start?
All replies much appreciated.
Thanks :)
Best place to start would be with the clients search functions. Just try sending your longtails as search terms and if it returns anything, that's your page
Andy, thanks for your reply. I agree with your approach, here's what I'm trying to do:
1) Rename the productlist.php page to something like sony-laptop.php.
2) Define a variable within sony-laptop.php as follows:
$KeyphrasePage = "sony laptop";
3) Pass that variable into the shopcore class found in classes/class.shopcore.php so that the variable is used as the search query.
I'm getting suck at point 3), I can't get the variable sent to the class properly. So far in classes/class.shopcore.php I've made an amendment to the code which defines the search query, such that when there's no search querystring it should use the manually set variable from 2) instead:
If (strlen($_GET['q']) > 0) {
$this->sQuery = strlen($_GET['q']) > 0 ? trim( strip_tags( urldecode($_GET['q']) ) ) : null;
}
Else {$this->sQuery = $KeyphrasePage;
}
... but I am not passing the variable $KeyphrasePage into the class correctly at all.
Any help with the correct syntax to use to pass the variable into the class would be very much appreciated.
Thanks and rgds
Any ideas guys?
I'm thinking if I try to send a variable to the class, that's not going to work, because then I'd have to send all the other variables as well.
I think I have to write a function which can change the new variable I've added?
Thanks and rgds
gjindancer
05-02-10, 19:03
I'm currently trying to do this dynamically, and it seems that you cannot pass a variable $keyphrase through the sQuery parameter, as there are urldecode and strip_tags functions on the sQuery variable in the class.shopcore.php file.
Removing these is bad for security as they are there to protect your site from malicious code insertion through your search form.
There could be other things which are a factor too though.
For static pages I have created a program which takes your product name, keywords and description and creates .php and .tpl files that use the squery function to display the relevant product and corresponding title/keywords and navigation. PM me for details.
Cheers
Dan
In all honesty, I think you're overthinking this.
Your idea either restricts you to 1 keyword/phrase, and/or you have 1 file per keyword/phrase.
Neither is a really workable thing.
As for passing the variable: $_GET['q'] is already passed, so all you need to do is intercept it before its passed to ensure it contains what you want. You could easily just add this to the very top of your file and it'll do what you want:
$_GET['q'] = 'Your Keyword';
Editing any of the classes is a bad idea unless you absolutely know what you're doing. They are designed to do specific jobs with dynamic data, so if you mess with them, you risk unpredictable results.
Best just to mess with the data that either gets sent to the class, of manipulate it once the class has dealt with it.
Andy
Thanks for your reply. I'm still looking at this and haven't cracked it, but just to give some feedback:
- 1 file per keyphrase is what I want, and I feel this should be workable.
- Yes, the querystring q is what currently controls the search results. However, I can't see how intercepting and modifying this in class.shopcore.php is workable, because I can't modify keyphrase data within class.shopcore.php without making the class specific to a particular keyphrase, I need to pass the keyphrase data to class.shopcore.php. Yes, I could do:
sony-laptop.php?q=sony+laptop
and pass the data in via a querystring, but that means every time I refer to my page url, I have to include a querystring.
- I think my main problem here is that class.shopcore.php contains the shopcore constructor method, and it's proving a bit difficult for me to work out how to pass a variable into a constructor.
... I just wanted to provide some feedback ... you could be right in what you're saying but I may not "get it".
Rgds
In all honesty, I think you're overthinking this.
Your idea either restricts you to 1 keyword/phrase, and/or you have 1 file per keyword/phrase.
Neither is a really workable thing.
As for passing the variable: $_GET['q'] is already passed, so all you need to do is intercept it before its passed to ensure it contains what you want. You could easily just add this to the very top of your file and it'll do what you want:
$_GET['q'] = 'Your Keyword';
Editing any of the classes is a bad idea unless you absolutely know what you're doing. They are designed to do specific jobs with dynamic data, so if you mess with them, you risk unpredictable results.
Best just to mess with the data that either gets sent to the class, of manipulate it once the class has dealt with it.
gjindancer
13-02-10, 18:26
You should not have to do anything with shopcore, all you need is a copy of the index.php page, named as you require with the following code in:
$oProductDisplayListParams->iCategoryId= $_GET['c'];
$oProductDisplayListParams->aMerchantIds= array($_GET['m']);
$oProductDisplayListParams->sQuery= 'Audio';
$oProductDisplayListParams->iLimit= $_GET['iListLimit'];
$oProductDisplayListParams->iOffset= $_GET['iListOffset'];
$oProductDisplayListParams->sSort= $_GET['sListSort'];
$oProductDisplayListParams->bStayOnPage= false;
$oProductDisplayListParams->bShowTopNav= true;
You then need to update a corresponding .tpl file for it to be displayed.
BTW I was wrong about the shopcore an security stuff - you can intercept and define "q" or sQuery quite easily.
Dan