Hi David,
AS the sales period gets up and running from Christmas eve onwards, I am wanting to list the URLs (text links) of all the retailers I feature so I could display in Alphabetical order in one of my sidebars or even show with the retailers logo (on the assumtion that I have the URL of the logos)
How can I do that?
Regards
Paul
Hi David,
Thanks for that!
I'm getting the following message
"Fatal error: Call to undefined function database_queryselect() in C:\Program Files\xampp\htdocs\wordpress\wp-content\themes\revolution_magazine-30\sidebar_right.php on line 36"
line 36 = database_querySelect($sql,$rows);
Any suggestions?
Cheers
Paul
Hi Paul,
If you're inserting the code with a Wordpress section (so not part of Price Tapestry); you'll need to include the Price Tapestry config file and database library, and I expect declare the database variables as global - add the following to the top of the code:
global $config_databaseServer;
global $config_databaseUsername;
global $config_databasePassword;
global $config_databaseName;
global $config_databaseTablePrefix;
require("/path/to/pricetapestry/config.php");
require("/path/to/pricetapestry/includes/database.php");
That should do the trick...
Cheers,
David.
David,
Top Man, that seem to have done it! Thanks and All the best
Don't suppose there's a way of incorporating merchants that don't have a datafeed?
Thanks
Paul
Hi Paul,
You could try something like this...
<?php
$links["Merchant 1"] = "http://www.example.com/";
$links["Merchant 2"] = "http://www.example.net/";
$sql = "SELECT * FROM `".$config_databaseTablePrefix."feeds` ORDER BY merchant";
database_querySelect($sql,$rows);
$rows[] = array("merchant" => "Another Merchant A");
$rows[] = array("merchant" => "Another Merchant B");
$merchants = array();
foreach($rows as $row)
{
$merchants[] = $row["merchant"];
}
sort($merchants);
print "<ul>";
foreach($merchants as $merchant)
{
print "<li><a href='".$links[$merchant]."'>".$merchant."</a></li>";
}
print "</ul>";
?>
Don't forget also to add the merchants links in the same way for the extras...
Cheers,
David.
David,
seems to be working to a degree, however the merchants I'm adding without a datafeed seem to appear behind the links with a datfeed as if the datafeed links were listed on the highest level layer with the links without on a layer underneath that makes sense?
I've added the links without a datafeed in the following way?
<?php
$links["Merchant 1"] = "http://www.example.com/";
$links["Merchant 2"] = "http://www.example.net/";
$sql = "SELECT * FROM `".$config_databaseTablePrefix."feeds` ORDER BY merchant";
database_querySelect($sql,$rows);
$rows[] = array("MY MERCHANT" => "http://www.myMerchant_affiliateid1236.co.");
$merchants = array();
foreach($rows as $row)
{
$merchants[] = $row["merchant"];
}
sort($merchants);
print "<ul>";
foreach($merchants as $merchant)
{
print "<li><a href='".$links[$merchant]."'>".$merchant."</a></li>";
}
print "</ul>";
?>
is that correct?
Thanks
Hi Paul,
Where you add merchants, they need to be like this:
$rows[] = array("merchant" => "MY MERCHANT");
...and then the URL you would add higher up (in the $links array) along with the URLs for merchants with feeds:
$links["MY MERCHANT"] = "http://www.myMerchant_affiliateid1236.co.";
Cheers,
David.
Hi David,
eventually did this live on my site and it comes back with this
Fatal error: Call to undefined function: database_queryselect() in /homepages/45/d229581650/htdocs/blog/wp-content/themes/revolution_magazine-30/sidebar_right.php on line 43, where Line 43 is database_querySelect($sql,$rows);?
Don't know why but it worked perfectly on my development site on localhost?? the only thing I changed were the "require" URLs
cheers
Paul
Hi Paul,
That would indicate that the path is not correct (I'm assuming this is running as standalone script rather than within a WP page). From the error message above, the require statements should be something like:
require("/homepages/45/d229581650/htdocs/pricetapestry/includes/database.php");
(where the /pricetapestry/ part of that line is identical to your $config_baseHREF setting in config.php)
Cheers,
David.
Hi David,
I'm such a numpty at times! you're right, I was trying to use the URL rather than the whereami script!
Sorry for time wasting. Oh! by the way, the new u[load.php script works fine, so thanks for that also.
Hi David,
I wanted to ask regarding this subject whether you know of any reason why I can't use the script in two places?
ie: the first is in the wordpress side bar which works ok, however using the exec.php plugin (allows you to embed php code in your wordpress posts and pages) I also have tried to use the same script in a post. As soon as I do that I get the following error in the side bar? "Fatal error: Cannot redeclare database_queryselect() (previously declared in /homepages/45/d229581650/htdocs/blog/Store/includes/database.php:3) in /homepages/45/d229581650/htdocs/blog/Store/includes/database.php on line 3" line 3 being ""
I don't understand? maybe my numptyness coming through again?
cheers Paul
Hi Paul,
That just sounds like, because you have already included the code once on the page (in the sidebar), you don't need to include the database library again in the second part (as long as the sidebar version is always going to be displayed on the same page).
Simply remove the following line from the second instance of the code (not the one in the sidebar) and it should then work fine...
require("......./database.php");
Cheers,
David.
Thanks again David,
As usual, Problem sorted!
Cheers
Paul
Hi Paul,
Perhaps it's best to re-instate the original require() line; but in each instance (both the sidebar and main code), change "require" to "require_once" - so you would have:
require_once("..../database.php");
That should prevent any conflict whenever you are using the code in more than one place.
Cheers,
David.
Hi david,
Any other suggestions? getting the same error message...
Thanks
Paul
Hi Paul,
Could you post the code you have added to the sidebar_right.php file (as mentioned in the error message) and i'll take a look (although I appreciate you may not have edited this file directly, but perhaps there is a configuration area within WP where you add code to appear in the right side-bar...)
Cheers,
David.
Hi David, This is the FULL code of sidebar_right.php
I do edit it directly into the WP code, normally isn't a prob.
<!-- begin r_sidebar -->
<div id="r_sidebar">
<ul id="r_sidebarwidgeted">
<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(3) ) : else : ?>
<li id="links">
<h2>Sales Shop</h2>
<?php
global $config_databaseServer;
global $config_databaseUsername;
global $config_databasePassword;
global $config_databaseName;
global $config_databaseTablePrefix;
require("/kunden/homepages/45/d229581650/htdocs/blog/Store/config.php");
require("/kunden/homepages/45/d229581650/htdocs/blog/Store/includes/database.php");
**** affiliate links taken out****
$sql = "SELECT * FROM `".$config_databaseTablePrefix."feeds` ORDER BY merchant";
database_querySelect($sql,$rows);
$rows[] = array("merchant" => "Coast");
$rows[] = array("merchant" => "Shoe Shop");
$rows[] = array("merchant" => "Freemans");
$rows[] = array("merchant" => "Kaleidascope");
$rows[] = array("merchant" => "Next");
$rows[] = array("merchant" => "Secret Sales");
$merchants = array();
foreach($rows as $row)
{
$merchants[] = $row["merchant"];
}
sort($merchants);
print "<ul>";
foreach($merchants as $merchant)
{
print "<li><a href='".$links[$merchant]."'>".$merchant."</a></li>";
}
print "</ul>";
?>
<li id="meta">
<h2>Admin</h2>
<ul>
<?php wp_register(); ?>
<li><?php wp_loginout(); ?></li>
<li><a href="http://www.wordpress.org/">WordPress</a></li>
<?php wp_meta(); ?>
<li><a href="http://validator.w3.org/check?uri=referer">XHTML</a></li>
</ul>
</li>
<?php endif; ?>
</ul>
</div>
<!-- end r_sidebar -->
Cheers
Paul
Hi Paul,
This is where I would recommend replacing require() with require_once()... i.e. instead of:
require("/kunden/homepages/45/d229581650/htdocs/blog/Store/config.php");
require("/kunden/homepages/45/d229581650/htdocs/blog/Store/includes/database.php");
...use:
require_once("/kunden/homepages/45/d229581650/htdocs/blog/Store/config.php");
require_once("/kunden/homepages/45/d229581650/htdocs/blog/Store/includes/database.php");
However, i'm not sure that is the problem in this instance, as function not found would indicate that one of those paths is incorrect - can you double check that...
Cheers,
David.
Hi David,
I really can't understand it? I've checked the path with the whereami.php script
/kunden/homepages/45/d229581650/htdocs/blog/Store/
Paul
Hi Paul,
I was going to suggest taking the database function itself out of database.php; but I'm assuming it is not including config.php either. Could you try adding the following code after the two require_once(...) lines, which should print out your database username - this will confirm whether or not the requires are working at all...
print "[".$config_databaseUsername."]";
(it will print the username out in square brackets, which will mean you should be able to see [] if it is not working...)
Cheers,
David.
Hi David,
Really don't know what's happening, but upon looking at the site now, it all seems to be OK?
so I'll monitor it and seem how we get on?
Thanks agin for your help!
Ps I saw an exchange between you and Mally regarding sharing PT between sites, whic is what I am wanting to do, need to ask a couple of questions. I will do that on that thread, cheers
Paul
Hi David,
Earlier in this thread when you were helping me with including merchants logos, you diercted me to a previous thread (node/314). Within that you stated
"...1) Create a sub-directory of your Price Tapestry installation called "logos".
2) Upload merchant logos into that directory using a filename that is exactly the same as the registered merchant name, without using any file extension. For example, if you have two merchants registered on your site called "Currys" and "Dixons", you would have:
/path/to/PriceTapestry/logos/Currys
/path/to/PriceTapestry/logos/Dixons"
a couple of things I need clarified please,
a. Can I confirm that you add a further sub directory to /logos/ for each merchant image you use, which includes the image file?
b. Do both the directory and image file need to be the exact same name of the registered name given to the merchant datafeed?
c. If I have given my feeds actual names of the merchants some of which includes breaks eg: House Of Fraser, how do I overcome this when you can't have a file names with breaks?
regards
Paul
Hi Paul,
You don't need to create separate directories per merchant, just upload the merchant logos with the filename exactly matching the registered merchant name into the /logos/ folder.
You should find that you can create a filename with spaces with no problem on Windows / Linux, but let me know if you can't (and what software you are using) and i'll look into a work-around for you...
Cheers,
David.
Hi Paul,
As there are no direct merchant links stored in the database; the easiest thing to do is get a list of merchants from the feeds table; and hard code an array with direct-to-merchant affiliate links for each of them; as follows:
<?php
$links["Merchant 1"] = "http://www.example.com/";
$links["Merchant 2"] = "http://www.example.net/";
$sql = "SELECT * FROM `".$config_databaseTablePrefix."feeds` ORDER BY merchant";
database_querySelect($sql,$rows);
print "<ul>";
foreach($rows as $row)
{
print "<li><a href='".$links[$row["merchant"]]."'>".$row["merchant"]."</a></li>";
}
print "</ul>";
?>
Adding logos is straight forward - have a look at the following thread:
http://www.pricetapestry.com/node/314
So assuming a folder called "logos" containing the merchant logos with a filename exactly matching the registered merchant name, the code above could be modified to use images instead as follows:
<?php
$links["Merchant 1"] = "http://www.example.com/";
$links["Merchant 2"] = "http://www.example.net/";
$sql = "SELECT * FROM `".$config_databaseTablePrefix."feeds` ORDER BY merchant";
database_querySelect($sql,$rows);
print "<ul>";
foreach($rows as $row)
{
print "<li><a href='".$links[$row["merchant"]]."'><img src='logos/".$row["merchant"]."' border='0' /></a></li>";
}
print "</ul>";
?>
Hope this helps!
Cheers,
David.