PDA

View Full Version : Latest Items from individual categories- home page



Jude
January 29, 2013, 04:38 AM
Hi, How do we add different blocks on the homepage that show the lastest items out of certain categories?

Viktor
January 29, 2013, 04:54 AM
Hello Jude,

You can install Listing Box Plugin for that, but this plugin will allow you show latest listings from all categories. If you want to show listings from certain categories it needs some changes. If you want I send you code for that.
At first implement listing box plugin and check it.

Jude
January 29, 2013, 05:07 AM
Hi Viktor, thank you for your reply and i have tested the listing box plugin and we would like to only show items from certain categories. If you could please supply the code that would be fantastic.. thanks! : )

Viktor
January 29, 2013, 06:30 AM
Hello Jude,

go to Admin Panel >> Listing Box click + Add new block button and create new box.

Then go to Admin Panel >> Content Boxes find block with want name like you created box and remember key for this block for me it's 'listing_box_1'

then go to phpMyAdmin(mysql database) >> blocks and find line with this key and click edit.

in Content field you can see:



global $reefless;
global $rlSmarty;

$reefless -> loadClass("ListingsBox", null, "listings_box");
global $rlListingsBox;
$listings_box = $rlListingsBox -> getListings( "listings", "recently_added", "10" );
$rlSmarty -> assign_by_ref( "listings_box", $listings_box );
$rlSmarty -> assign( "type", "listings" );


$rlSmarty -> display( RL_PLUGINS . "listings_box" . RL_DS . "listings_box.block.tpl" );


find line:


$listings_box = $rlListingsBox -> getListings( "listings", "recently_added", "10" );

and replace to:


$listings_box = $rlListingsBox -> getListings( "listings", "recently_added", "10", 'books/accessories' );

where: 'books/accessories' it's category path. Where you want to take listings.

and save it.

Then go to ftp://plugins>>listing_box>>rlListingsBox.class.php

find method: getListings and code:


function getListings( $type = false, $order = false , $limit = false )

and replace to:

function getListings( $type = false, $order = false , $limit = false, $category_path = false )

then find code:

$sql .= "AND `T1`.`Status` = 'active' AND `T7`.`Status` = 'active' ";

and after it add new code:



if( $category_path )
{
$sql .= "AND `T3`.`Path` = '{$category_path}' ";
}


save and check.

Jude
January 30, 2013, 04:20 AM
That worked perfectly thank you :)

Maaz Surchy
February 15, 2013, 10:49 AM
Thank you Viktor, very nice done it

Ameer Hassan
July 29, 2014, 11:16 AM
Didn't worked for me :( can i get help here?

Viktor
July 29, 2014, 01:32 PM
Hello Ameer,

Did you use all the code which I wrote above?

Jahid Zaynal
July 29, 2014, 09:39 PM
Hi Viktor, your first post is more than a year and a half old, is it still relevant with the latest Flynax software? Because I couldn't follow your steps.

I can create a Content Box (from Admin Panel->Content->Add a Content Box) but it asks me to select a box type: HTML, PHP or Smarty. Which one do I choose and what do I include in the content field?

Viktor
July 30, 2014, 03:25 AM
Hello Jahid,

Please read my post more thoroughly because I wrote at first create a box in Listing Box plugin into admin panel:
>>go to Admin Panel >> Listing Box click + Add new block button and create new box.

Jahid Zaynal
July 30, 2014, 12:48 PM
But I can't find the "+ Add new block" button you're referring to. Here's what I want: Show latest adverts (from all categories) in a slider or a content box in home page.
Can you please walk me through the steps of doing just that? Thanks

Chris Brown
July 30, 2014, 01:15 PM
I would just install listing box plugin and the listing carousel plugin.

Then In Listing box plugin section in admin create a block of recently added listings. Then use the carousel plugin to turn the box into a slider

Jahid Zaynal
July 30, 2014, 01:20 PM
Chris, when I install the listings box plugin, it only shows new and popular "Boats", while I don't even have boats as one of my categories. I couldn't make it to show Autos or other categories that I have. Is the listings box plugin explained in the manual? If so I'll have a look to understand how it works.

Jahid Zaynal
July 30, 2014, 01:21 PM
Lol, it's easy to say "create a block of recently added listings" but it's not that easy to do it on the Admin panel. Flynax admin panel lacks clarity and it's definitely NOT intuitive!

Jahid Zaynal
July 30, 2014, 01:39 PM
I don't know if something is wrong with my installation but I don't see the plugins that I activate under the "Plugins" tab.
1053

Is that how it should be or should the activated plugins be in the list?

Chris Brown
July 30, 2014, 02:19 PM
If you have listing box plugin installed and activated it should show in that list. Then you would usually click listing box there which takes you to box configuration,

You could try removing plugin from files on server and then re installing

Jahid Zaynal
July 30, 2014, 05:42 PM
That was correct! I had to delete the plugin folder and then install it from the admin panel plugins tab. it works now :) thanks

Chris Brown
July 30, 2014, 05:54 PM
Great glad its sorted

Mahmoud Khedr
September 21, 2015, 09:44 PM
thank you .........

Horizon
January 14, 2024, 05:59 AM
This is an old thread so I just want to check for an update to the 2013 post (https://forum.flynax.com/showthread.php?978-Latest-Items-from-individual-categories-home-page&p=4104&viewfull=1#post4104)

Looking at rlListingsBox.class.php 4.9.2 version it looks to me like the by_category option is already built in.

Line 158 in rlListingsBox.class.php reads:

public function getListings($type, $order, $limit = 0, $unique = 0, $by_category = 0)

And my recent listing box already has by default extra values from the 2013 post above
getListings( "listings", "recently_added", "10", "0", "0" );

Which I assume corresponds to
type=listings
order=recently added
limit=show 10 listings
unique=(not sure how to use unique)
by_category=(is this category id# or category name?)

I tried both the main category name and the category ID in that final spot, and it's not limiting to category 623.
I got the category ID from doing a get search that shows the category I want
Category_ID%5D=623&f%5Bcategory_parent_ids%5D=623

Do I specify by category name or id?
As of 4.9.2, do I still need to do a modification as in the past to make this work, or is this built in already now as it appears to be? Anything else I need to do to create a box that includes listings from one specific category now in 4.9.2?

Horizon
January 16, 2024, 07:35 AM
The default recently added content block has the code:


global $rlSmarty;
$GLOBALS["reefless"]->loadClass("ListingsBox", null, "listings_box");
$listings_box = $GLOBALS["rlListingsBox"] -> getListings( "listings", "recently_added", "10", "0", "0" );
$rlSmarty->assign_by_ref("listings_box", $listings_box);
$rlSmarty->assign("type", "listings");$box_option["display_mode"] = "default";$rlSmarty->assign("box_option", $box_option);
$rlSmarty->display(RL_PLUGINS . "listings_box" . RL_DS . "listings_box.block.tpl");



I want to show the newest 4 ads from the category with ID 623, so I created a new content box as follows:

type: php



global $rlSmarty;
$GLOBALS["reefless"]->loadClass("ListingsBox", null, "listings_box");
$listings_box = $GLOBALS["rlListingsBox"] -> getListings( "listings", "recently_added", "4", "0", "623" );
$rlSmarty->assign_by_ref("listings_box", $listings_box);
$rlSmarty->assign("type", "listings");$box_option["display_mode"] = "default";$rlSmarty->assign("box_option", $box_option);
$rlSmarty->display(RL_PLUGINS . "listings_box" . RL_DS . "listings_box.block.tpl");

but it doesn't limit it to the category with id 623, it still shows recent listings from all categories.

Is there something else I should enter in this block to make it show the recent listings only from category 623?
Or do I have to still do a code modification to make this work as in earlier years?

Horizon
January 17, 2024, 09:30 AM
Any tip on using a content block to show images from only one category? I must be missing something in the post above, but I can't see it even after looking at it for an hour. Have a feeling it is something simple that I'm not seeing ;)

Rudi
January 18, 2024, 10:14 AM
Go to plugins/listings_box/rlListingsBox.class.php > public function getListings

after:


$sql .= "WHERE `T1`.`Status` = 'active' ";


add:


if ($by_category > 1) {
$sql .= "AND `T1`.`Category_ID` = '{$by_category}' ";
}

Horizon
January 18, 2024, 03:09 PM
Fantastic! Works great. Thank you Rudi! :)