Hello David,
I have created a sidebox in the older version of your script. Can you tell me how i can add only the main categories vertical in it? Like this (also with stripe or bullit):
- Bedden
- Bedtextiel
- Bergkasten
- Bijzettafels
- Boekenkasten
- Boxsprings
- Buffetkasten
- Bureaus
Thank you Jan Roel
Hello David,
Thanks. And when i place the code in the sidebox it shows up like this:
- Bedden
- Bedtextiel
- Bergkasten
- Bijzettafels
- Boekenkasten
- Boxsprings
- Buffetkasten
- Bureaus
Thanks Jan Roel
Hello Jan,
Here's the complete code for a list of top level categories;
$sql = "SELECT name AS category FROM `".$config_databaseTablePrefix."categories_hierarchy` WHERE parent='0' ORDER BY category";
database_querySelect($sql,$rows);
print "<ul>";
foreach($rows as $row)
{
print "<li><a href='".tapestry_indexHREF("category",$row["category"])."'>".$row["category"]."</a></li>";
}
print "</ul>";
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
Hello David,
Thank you very much! Happy with it. Do you maybe know the trick (when the menu has for example more then 20 categories) how to collapse the menu?
Hello Jan,
This is the technique used to reveal the search filters in mobile view - the general idea being; put the content to be revealed inside a <div> with the display style set to "none". In a separate element the "Show more..." text has a JavaScript onclick handler that then hides itself and reveals the currently hidden <div> by setting the display style back to "block"...
$sql = "SELECT name AS category FROM `".$config_databaseTablePrefix."categories_hierarchy`
WHERE parent='0' ORDER BY category";
database_querySelect($sql,$rows);
$max = 20;
print "<ul>";
foreach($rows as $k => $row)
{
print "<li><a href='".tapestry_indexHREF("category",$row["category"])."'>".$row["category"]."</a></li>";
if ($k==($max-1))
{
print "<li id='more1show'
onclick='JavaScript:this.style.display=\"none\";
document.getElementById(\"more1\").style.display=\"block\"'>Show more...</li>";
print "<div id='more1' style='display:none;'>";
}
}
print "</div>";
print "</ul>";
Cheers,
David.
--
PriceTapestry.com
Hello David,
Thank you very much! Only one problem the categories aren't showing up. Is the problem maybe because of this topic? I use multiple installation.
I placed the code like this in my website (html/banner.php):
{code saved}
<?php
$merchant = trim(file_get_contents("merchant.txt"));
$sql = "SELECT DISTINCT(name) AS category FROM `".$config_databaseTablePrefix."categories_hierarchy` WHERE merchant='".database_safe($merchant)."' ORDER BY category";
?>
Thanks Jan Roel
Hello Jan,
There's no `merchant` field on the categories_hierarchy table but you could do it with a sub-query on the products table; have a go with:
<?php
$merchant = trim(file_get_contents("merchant.txt"));
$sql = "SELECT DISTINCT(name) AS category FROM `".$config_databaseTablePrefix."categories_hierarchy` WHERE id IN ( SELECT DISTINCT(categoryid) FROM `".$config_databaseTablePrefix."products` WHERE merchant='".database_safe($merchant)."') AND parent='0' ORDER BY category";
?>
Cheers,
David.
--
PriceTapestry.com
Hello David,
When i add this code into html/banner.php
{code saved}
Then i get this error:
{code saved}
Thanks Jan Roel
Hello Jan,
My apologies, it's actually `categoryid` not `category_id` on the products table. Corrected above, however it occurred to me that an additional step is required, as the sub-query is not necessarily returning top level categories. The following should do the trick, which scans each top level category for at least one sub-category containing products from the merchant selected from your merchant.txt file...
<?php
$merchant = trim(file_get_contents("merchant.txt"));
$sql = "SELECT id,name AS category FROM `".$config_databaseTablePrefix."categories_hierarchy`
WHERE parent='0' ORDER BY category";
database_querySelect($sql,$rows);
foreach($rows as $k => $row)
{
$rows[$k]["lowerarchy"] = tapestry_categoryHierarchyLowerarchy($id);
}
$sql2 = "SELECT DISTINCT(categoryid) FROM `".$config_databaseTablePrefix."products` WHERE merchant='".database_safe($merchant)."'";
database_querySelect($sql2,$rows2);
foreach($rows as $k => $row)
{
$found = FALSE;
foreach($rows2 as $row2)
{
if (in_array($row2["categoryid"],$rows[$k]["lowerarchy"]))
{
$found = TRUE;
break;
}
}
if (!$found) unset($rows[$k]);
}
$max = 20;
print "<ul>";
foreach($rows as $k => $row)
{
print "<li><a href='".tapestry_indexHREF("category",$row["category"])."'>".$row["category"]."</a></li>";
if ($k==($max-1))
{
print "<li id='more1show'
onclick='JavaScript:this.style.display=\"none\";
document.getElementById(\"more1\").style.display=\"block\"'>Show more...</li>";
print "<div id='more1' style='display:none;'>";
}
}
print "</div>";
print "</ul>";
?>
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
Hello David,
The strange thing is nothing showes up when adding the code in html/banner.php. The product section is moving completly to the left. See here: {link saved}
Do you now how this is possible? I use this node for creating sidebar: http://www.pricetapestry.com/node/5821
Jan Roel
Hello Jan,
Please could you email me modified html/banner.php and i'll check it out further with you...
Thanks,
David.
--
PriceTapestry.com
Hello david,
How can i add also a sidebox to the homepage? I use html/featured.php.
{code saved}
Thanks Jan Roel
Hello Jan,
To put a sidebar alongside (or above for mobile view) Featured Products on the home page, edit index.php and look for the following code at line 47:
if (isset($featured)) require("html/featured.php");
...and REPLACE with:
?>
<div class='row'>
<div class='small-12 medium-2 columns'>
<!-- sidebar content here -->
</div>
<div class='small-12 medium-10 columns'>
<?php
if (isset($featured)) require("html/featured.php");
?>
</div>
</div>
<?php
Cheers,
David.
--
PriceTapestry.com
Thank you very much David,
I feel myself very stupid. Normally i can create some css stuff but now i can't fix it.
I want the font size of the category has the same size as the product title. But everything i do nothing works.
Thanks Jan roel
Hello Jan,
Featured Products name font size is inheriting the body font size (12px) but it looks like Foundation is styling <ul><li>... differently, so what you can do is give a class to the list and then set the font size as required.
In the category sidebar code from above, where you have the opening <ul> being output by this line:
print "<ul>";
...REPLACE with:
print "<ul class='pt_sidebar_cat'>";
And then to html/default.css add the following:
.pt_sidebar_cat li a {
font-size: 12px !important;
}
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
Hello Jan,
If your old version is using this SQL:
$sql = "SELECT DISTINCT(category) FROM `".$config_databaseTablePrefix."products` WHERE category <> '' ORDER BY category";
Then with 15/09A / Category Hierarchy, to get the top level categories you can just replace that with:
$sql = "SELECT name AS category FROM `".$config_databaseTablePrefix."categories_hierarchy` WHERE parent='0' ORDER BY category";
If your initial select is not quite the same as above or you're not sure how to modify the example for 15/09A to suit your code let me know what you're currently using and I'll show you how to modify as required...
Cheers,
David.
--
PriceTapestry.com