Created info sections as per http://www.pricetapestry.com/node/3237
Is there any way to also do this for Merchants and Featured pages in Admin?
Très happy camper, David! Works as expected, managed to get operating as I need.
Re Featured Products: I have an include at the bottom, but would like to have it in the sidebar. I'm using my site's template and integrated PT brand, merchant and category info code I want there. So I was hoping there was some way to do a script that would display only on the index page. I would have an html or php file with the info as an include, but somehow, have code around that to only display that file on the index page. I hope this makes sense.
Hi,
You can use $_SERVER["PHP_SELF"] to find out what page you are on and include / exclude code as required, for example in your sidebar;
<?php
if ($_SERVER["PHP_SELF"]=="/index.php")
{
require("featured.html");
}
?>
Cheers,
David.
--
PriceTapestry.com
Not working, but maybe as index.php is redirected to /shops/, which I tried, also "shops/" and just "/"...but no luck.
Hi,
$_SERVER["PHP_SELF] is relative to top level including leading "/", have a go with:
<?php
if ($_SERVER["PHP_SELF"]=="/shops/index.php")
{
require("featured.html");
}
?>
If still no joy, add some temporary debug code to print the value e.g.
<?php print "[".$_SERVER["PHP_SELF"]."]"; ?>
...and then look for the correct value to use displayed in [square brackets]...
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
I added this handy dandy code in the header.php to add an H1 title on the index page. Thank you again!
Hi,
I was previously using merchant_info folder and adding separate HTML files. This has become cumbersome so I have followed these steps. How do I get the info to show on the merchant page?
I would like it to appear at https://www.example.com/merchant/xxxxx/ before the search results are returned. And then maybe on the product page??
Thanks
Richard
Hi Richard,
To show merchant info on page 1 search results only (to avoid duplicate content issues) add the following PHP section to the top of html/searchresults.php
<?php
if (($page==1) && isset($parts[1]) && ($parts[0]=="merchant"))
{
$sql = "SELECT * FROM `".$config_databaseTablePrefix."merchant_info` WHERE name='".database_safe($parts[1])."'";
if (database_querySelect($sql,$rows))
{
print "<div class='row'><div class='small-12 columns'><p>".$rows[0]["info"]."</p></div></div>";
}
}
?>
Bear in mind that there may be more than one merchant in context on product pages, and there is also the possibility of duplicate content issues if the same merchant info is shown on hundreds of product pages but to show merchant info for the cheapest merchant you can use $product_main["merchant"] - let me know if you're not sure of course...
Cheers,
David.
--
PriceTapestry.com
Hi David, Merry christmas and happy new year.
I am trying to add 3 more fields to marchant info,
fields are
1. Delivery_time
2. Delivery cost
3. Buyers-feedback
example
Delivery time : 2-4 days
Delivery cost : £2 and FREE SHIPPING ABOVE £50
Feedback: 95% possitive
Hi and seasons greetings to you to and best wishes for the new year!
Here's a dbmod.php (run once from top level) to add the new fields:
<?php
require("includes/common.php");
$sql = "ALTER TABLE `".$config_databaseTablePrefix."merchant_info`
ADD `delivery_time` VARCHAR(255) NOT NULL default '',
ADD `delivery_cost` VARCHAR(255) NOT NULL default '',
ADD `buyers_feedback` VARCHAR(255) NOT NULL default ''
";
database_queryModify($sql,$result);
print "Done.";
?>
And then to add the new fields to admin/merchant_info_configure.php look for the following code at line 20:
$sql = "UPDATE `".$config_databaseTablePrefix."merchant_info` SET info = '".database_safe($_POST["info"])."' WHERE id='".database_safe($id)."'";
...and REPLACE with:
$sql = "UPDATE `".$config_databaseTablePrefix."merchant_info` SET info = '".database_safe($_POST["info"])."',delivery_time = '".database_safe($_POST["delivery_time"])."',delivery_cost = '".database_safe($_POST["delivery_cost"])."',buyers_feedback = '".database_safe($_POST["buyers_feedback"])."' WHERE id='".database_safe($id)."'";
And then the following code at line 31:
widget_textArea("","info",FALSE,$merchant_info["info"],200,12);
...and REPLACE with:
widget_textArea("Info","info",FALSE,$merchant_info["info"],200,12);
widget_textBox("Delivery Time","delivery_time",FALSE,$merchant_info["delivery_time"]);
widget_textBox("Delivery Cost","delivery_cost",FALSE,$merchant_info["delivery_cost"]);
widget_textArea("Buyers Feedback","buyers_feedback",FALSE,$merchant_info["buyers_feedback"],200,12);
Cheers,
David.
--
PriceTapestry.com
Hi David.
I am trying to show this info on product page too.
example:
Delivery time : 2-4 days
Delivery cost : £2 and FREE SHIPPING ABOVE £50
Feedback: 95% possitive
it works on merchant page but not product page. Here is the code I am using
<?php
if (($page==0) && isset($parts[1]) && ($parts[0]=="merchant"))
{
$sql = "SELECT * FROM `".$config_databaseTablePrefix."merchant_info` WHERE name='".database_safe($parts[1])."'";
if (database_querySelect($sql,$rows))
{
print "<div class='callout-merchant'>";
print "<div class='row'>";
print "<div class='col-xs-12 col-md-12 card-intro-one'>";
print "<h1 class='mainintro'>".$parts[1]."</h1>";
print "<span class='mainrating'>".$rows[0]["buyers_feedback"]." ".translate("Positive")."</span>";
print "<p class='briefer'>".translate("Delivery time")." <strong>".$rows[0]["delivery_time"]."</strong></p>";
print "<p class='briefer'>".translate("Free Delivery")." <strong>".$rows[0]["delivery_cost"]."</strong></p>";
print "</div>";
print "<div class='col-xs-12 col-md-8 card-intro-seco'>";
print "<p><strong>".translate("Brief about")." ".$parts[1]."</strong></p>";
print "<p class='briefer'>".$rows[0]["info"]."</p>";
print "</div></div> ";
print "</div>";
}
}
?>
And if you can separete php from html/css that will be great, Thank your long lasting support.
Hi,
Try this for product page (in html/product.php)
<?php
$sql = "SELECT * FROM `".$config_databaseTablePrefix."merchant_info` WHERE name='".$product_main["merchant"]."'";
if (database_querySelect($sql,$rows));
$merchant_info = $rows[0];
?>
<div class='callout-merchant'>
<div class='row'>
<div class='col-xs-12 col-md-12 card-intro-one'>
<h1 class='mainintro'><?php print $merchant_info["name"]; ?></h1>
<span class='mainrating'><?php print $merchant_info["buyers_feedback"]; ?> <?php print translate("Positive");?></span>
<p class='briefer'><?php print translate("Delivery time");?> <strong><?php print $merchant_info["delivery_time"]; ?></strong></p>
<p class='briefer'><?php print translate("Free Delivery");?> <strong><?php print $merchant_info["delivery_cost"]; ?></strong></p>
</div>
<div class='col-xs-12 col-md-8 card-intro-seco'>
<p><strong><?php print translate("Brief about");?> <?php print $merchant_info["name"]; ?></strong></p>
<p class='briefer'><?php print $merchant_info["info"]; ?></p>
</div></div>
</div>
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
Hi,
I assume for category / brand you have implemented as extensions to Category / Brand Mapping. For Merchant info, first create a table to hold the merchant info text by running the following dbmod.php script;
<?php
require("includes/common.php");
$sql = "CREATE TABLE `".$config_databaseTablePrefix."merchant_info` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) NOT NULL default '',
`info` text,
PRIMARY KEY (`id`)
) ENGINE=MyISAM
";
database_queryModify($sql,$result);
print "Done.";
?>
And then, based on the original category / brand info scripts (from the download), have a go with the following;
admin/merchant_info.php
<?php
require("../includes/common.php");
$admin_checkPassword = TRUE;
require("../includes/admin.php");
require("../includes/widget.php");
if (isset($_POST["submit"]) && isset($_POST["name"]))
{
widget_required("name");
if (!widget_errorCount())
{
$sql = "SELECT name FROM `".$config_databaseTablePrefix."merchant_info` WHERE name='".database_safe($_POST["name"])."'";
if (database_querySelect($sql,$rows))
{
widget_errorSet("name","merchant name already exists");
}
}
if (!widget_errorCount())
{
$sql = sprintf("INSERT INTO `".$config_databaseTablePrefix."merchant_info` SET
name = '%s'
",
database_safe($_POST["name"])
);
database_queryModify($sql,$insertId);
header("Location: merchant_info_configure.php?id=".$insertId);
exit();
}
}
require("admin_header.php");
print "<h2>".translate("Merchant Info")."</h2>";
print "<h3>".translate("New Merchant")."</h3>";
widget_formBegin();
widget_textBox("Name","name",TRUE,(isset($_POST["name"])?$_POST["name"]:""),"",3);
widget_formButtons(array("Add"=>TRUE));
widget_formEnd();
$sql = "SELECT * FROM `".$config_databaseTablePrefix."merchant_info` ORDER BY name";
if (database_querySelect($sql,$rows))
{
print "<h3>Existing Merchants</h3>";
print "<table>";
foreach($rows as $merchant_info)
{
print "<tr>";
print "<th class='pta_key'>".$merchant_info["name"]."</th>";
print "<td>";
admin_tool("Configure","merchant_info_configure.php?id=".$merchant_info["id"],TRUE,FALSE);
admin_tool("Delete","merchant_info_delete.php?id=".$merchant_info["id"],TRUE,TRUE,"alert");
print "</td>";
print "</tr>";
}
print "</table>";
}
require("admin_footer.php");
?>
admin/merchant_info_configure.php
<?php
require("../includes/common.php");
require("../includes/widget.php");
$id = $_GET["id"];
$sql = "SELECT * FROM `".$config_databaseTablePrefix."merchant_info` WHERE id='".database_safe($id)."'";
database_querySelect($sql,$rows);
$merchant_info = $rows[0];
$submit = (isset($_POST["submit"])?$_POST["submit"]:"");
if ($submit == "Cancel")
{
header("Location: merchant_info.php");
exit();
}
if ($submit == "Save")
{
if (!isset($_POST["info"]))
{
$_POST["info"] = "";
}
$sql = "UPDATE `".$config_databaseTablePrefix."merchant_info` SET info = '".database_safe($_POST["info"])."' WHERE id='".database_safe($id)."'";
database_queryModify($sql,$insertId);
header("Location: merchant_info.php");
exit();
}
require("admin_header.php");
print "<h2>Merchant Info (Edit Merchant)</h2>";
print "<h3>".$merchant_info["name"]."</h3>";
print "<div class='row'>";
print "<div class='small-6 columns'>";
widget_formBegin();
widget_textArea("","info",FALSE,$merchant_info["info"],200,12);
widget_formButtons(array("Save"=>TRUE),"merchant_info.php");
widget_formEnd();
print "</div>";
print "</div>";
require("admin_footer.php");
?>
admin/merchant_info_delete.php
<?php
require("../includes/common.php");
$id = $_GET["id"];
$sql = "DELETE FROM `".$config_databaseTablePrefix."merchant_info` WHERE id='".database_safe($id)."'";
database_queryModify($sql,$insertId);
header("Location: merchant_info.php");
exit();
?>
Then, you can use something like;
if ($parts[0]=="merchant")
{
$sql = "SELECT info FROM `".$config_databaseTablePrefix."merchant_info`
WHERE name = '".database_safe($parts[1])."'";
if (database_querySelect($sql,$rows))
{
print $rows[0]["info"];
}
}
(if you're not sure how to use merchant_info table in the same way as you are currently displaying category / brand info let me know where / how it is required and I'll point you in the right direction).
Regarding Featured Products, since there are not multiple values I would suggest simply making an html edit to html/featured.php as required, that way you can contain whatever content you wish within the Foundation markup easily...
Hope this helps!
Cheers,
David.
--
PriceTapestry.com