You are here:  » Merchant and Featured info sections

Active Forum Topics


Merchant and Featured info sections

Submitted by Retro135 on Sat, 2016-12-03 21:33 in

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?

Submitted by support on Mon, 2016-12-05 12:00

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

Submitted by Retro135 on Wed, 2016-12-07 00:18

Très happy camper, David! Works as expected, managed to get operating as I need.

Submitted by Retro135 on Wed, 2016-12-07 02:20

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.

Submitted by support on Wed, 2016-12-07 11:13

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

Submitted by Retro135 on Wed, 2016-12-07 12:48

Not working, but maybe as index.php is redirected to /shops/, which I tried, also "shops/" and just "/"...but no luck.

Submitted by support on Wed, 2016-12-07 12:52

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

Submitted by Retro135 on Wed, 2016-12-07 13:03

Perfect, thank you!

Submitted by Retro135 on Thu, 2017-01-26 04:03

I added this handy dandy code in the header.php to add an H1 title on the index page. Thank you again!

Submitted by babyuniverse on Fri, 2020-02-21 03:33

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

Submitted by support on Fri, 2020-02-21 09:46

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