Basic Listings Theme: Display User's Listings on Homepage
7 posts by 2 authors in: Forums > CMS Builder
Last Post: June 7, 2018 (RSS)
By gversion - May 18, 2018
Hello,
I have bought the Basic Listings theme and I would like to be able to display a user's listings on their homepage. What's the best way to do this please?
Thank you,
Greg
By leo - May 22, 2018
Hi Greg,
You just need to get the user's listings records by using their num (depending on how you link the listings with the user), and have a foreach loop to display them.
Let me know if you have any questions!
Thanks,
interactivetools.com
By gversion - June 7, 2018
Hi Leo,
I am displaying a user's listing with the following code, which takes the user's num from the URL (userNum):
// get the createdByUserNum value from the URL
$listingOwner = " listings.createdByUserNum='".@$_REQUEST['userNum']."'";
// load records from 'listings'
list($showcasesRecords, $showcasesMetaData) = getRecords(array(
'tableName' => 'listings',
'joinTable' => 'accounts',
'loadUploads' => true,
'allowSearch' => true,
'where' => $listingOwner,
'orderBy' => $pricesort,
'perPage' => '1',
));
The problem is that when I change the URL to a permalink then the userNum value is lost.
Could you please tell me how I can get around this issue?
Thanks,
Greg
By leo - June 7, 2018
Hi Greg,
Did you generate the permalinks by using update tables feature or creating custom permalinks? Try using $_REQUEST['num'] instead of $_REQUEST['userNum'] and let me know if the issue is fixed.
Thanks,
interactivetools.com
By gversion - June 7, 2018
Hi Leo,
Thanks for getting back to me.
The permalink is a field I have added to the accounts table and then I just manually choose a SEO friendly URL.
When I use $_REQUEST['num'] then the listing's num is retrieved rather than the createdByUserNum, which is what I want.
Thanks,
Greg
By leo - June 7, 2018
Hi Greg,
Can you try set getRecords() allowSearch to be false and use $_REQUEST['num'] for the where statement?
interactivetools.com