Hello!
I'd like to create a navigation block that lists recently created categories in descending order (most recent at the top, is what I'm trying to say).
Is there a tutorial for this?
Thanks!
T
Hello!
I'd like to create a navigation block that lists recently created categories in descending order (most recent at the top, is what I'm trying to say).
Is there a tutorial for this?
Thanks!
T
The category links that appear in the "Product Catalog" navigation block can be sorted via the instructions on this page:
http://squirrelcart.com/help/?Changi...t%20Order.html
To show newer categories at the top, you can sort by record_number - descending.
That is not going to exclude categories that were created prior to a certain date.
Thanks,
Jamie
PHP shopping cart software - Squirrelcart
Please rate or review us!![]()
Hotscripts ● PHP Resource Index
If you want a separate navigation block that will display the newest categories, try this....
1. Create a new navigation block
2. Put this in the Content field:
PHP Code:<div class="nav_link_container cat_links">
<ul class="nav_links">
<?php sc_category_links(sc_query('SELECT * FROM Categories ORDER BY record_number DESC LIMIT 0,5')); ?>
</ul>
</div>
3. The 5 in the code above controls how many categories it will display. In this case, it will show links for the last 5 category records added.
4. Add that navigation block to your storefront page
Thanks,
Jamie
PHP shopping cart software - Squirrelcart
Please rate or review us!![]()
Hotscripts ● PHP Resource Index
Can one modify that code just a bit to display the most recent products added instead of categories in a navigation block?
That will show the 5 newest products in a nav block.PHP Code:<?php
$prods = sc_query('
SELECT
record_number
,IF(Display_Name,Display_Name,Name) AS Name
FROM
Products
WHERE
Not_For_Sale !=1
ORDER BY
Date_Added_to_Cart DESC
LIMIT
0,5
');
if (empty($prods)) return;
?>
<div class="nav_link_container cat_links">
<ul class="nav_links">
<?php foreach($prods as $prod): ?>
<li>
<a href="<?php print get_product_url($prod['record_number'])?>"><?php print sc_htmlspecialchars($prod['Name'])?></a>
</li>
<?php endforeach; ?>
</ul>
</div>
Thanks,
Jamie
PHP shopping cart software - Squirrelcart
Please rate or review us!![]()
Hotscripts ● PHP Resource Index
Thanks, that's great. One last requet. Where the " Not_For_Sale !=1" is....
What would I add to it to get the right field where it would only display items where cost is not $0?
I have a "Used Equipment" category where customers can submit items via email to me that I will post as a product. I don't sell it for them thus the $0 cost, but list the items on my website as a product to create a draw where people will come back periodically to check out stuff.
Beery
Base_Price > 0
as in:
</span>PHP Code:<?php
$prods = sc_query('
SELECT
record_number
,IF(Display_Name,Display_Name,Name) AS Name
FROM
Products
WHERE
Not_For_Sale !=1
AND Base_Price > 0
ORDER BY
Date_Added_to_Cart DESC
LIMIT
0,5
');
if (empty($prods)) return;
?>
<div class="nav_link_container cat_links">
<ul class="nav_links">
<?php foreach($prods as $prod): ?>
<li>
<a href="<?php print get_product_url($prod['record_number'])?>"><?php print sc_htmlspecialchars($prod['Name'])?></a>
</li>
<?php endforeach; ?>
</ul>
</div>
Thanks,
Jamie
PHP shopping cart software - Squirrelcart
Please rate or review us!![]()
Hotscripts ● PHP Resource Index
Thanks Jamie. Much appreciated.
Beery
You're welcome![]()
Thanks,
Jamie
PHP shopping cart software - Squirrelcart
Please rate or review us!![]()
Hotscripts ● PHP Resource Index
Thank, Jamie!
This code is working great:
<div class="nav_link_container cat_links">
<ul class="nav_links">
<?php sc_category_links(sc_query('SELECT * FROM Categories ORDER BY record_number DESC LIMIT 0,5')); ?>
</ul>
</div>
One more question, I'd like to show the image associated with each category rather than just the name of the category. Is that possible?
The sc_category_links() function uses the product_catalog_nav_link.tpl.php template file to obtain the HTML for each link. You would need to alter that template file to add the category's image. You are going to find 2 anchor tags in that template, at line #10 and line #21. To change the name of the category to a link, you need to change:
to:PHP Code:<?php print $Name ?>
That will display the image you assigned to the category's "Image" field. If you want to use the "Image of Name" field instead, change that variable to "$Image_of_Name".PHP Code:<img src="<?php print SC_IMG_DIR_DYN."/$Image" ?>" alt="<?php print $Name?>" />
Thanks,
Jamie
PHP shopping cart software - Squirrelcart
Please rate or review us!![]()
Hotscripts ● PHP Resource Index
Thanks Jamie!
I added "$Thumbnail_Image" to show the thumbnail, and it looks nice!
T
There are currently 1 users browsing this thread. (0 members and 1 guests)