Add an RSS Feed to the Seller Store

Many of you are using the seller store module that 68 Classifieds offers for free. Although this isn’t really a “Store”, it is simply a place where the seller can show a store name, description and an image. This is only shown when you click on the link when viewing an ad listing that says, more ads from this seller and the seller has of course provided these items.

If you are taking advantage of this module, it only makes sense that you would want to include an RSS Feed for the seller as typically a seller that has a seller store would be a business seller such as an auto dealer or realtor.

It’s actually quite simple to add this feed. You will need to modify two files and possibly three depending on how thorough you want to be. You will most likely also want to have an RSS image to give it that polished and professional look.
RSS image logo I would recommend that you put this image in your templates images folder.
yourclassifiedsite/templates/yourtemplate/images

Now that you have the image in place, let’s first modify the seller store file to make the variable that you need available to your seller store. You will need to modify the mod_user.php file. Please ensure that you have made a backup of the seller store module and have that in a safe place! OK, so the file lives here:
yoursite/modules/seller_store/mod_user.php
Make sure that you open this with a plain text editor or a page editor that does NOT add additional code automatically.

In the mod_user.php file around line 32 you should find this code:
$class_tpl->assign('storeImage', $rs['sImage']);
What we want to do is add another variable and assign it to the template in addition to the items that are already there. To do this, we simply need to add this line right after the line above:
$class_tpl->assign('owner', $rs['sUserID']);
Please make sure that you have the semi-colon “;” at the end of the line and that you have the right brace “}” on the line right after it. Now save that file and upload it to your server overwriting the original.

What did we just do? The file already did a database query, but it didn’t assign all of the fields to variables in the template. So what we did was simply take the field “sUserID” which the database query already got and assigned it to the variable that we called owner.

For the more technical and curious at heart, I’ll explain full circle how this file is used. As this is a module, the module is used in a module hook. The module hook is located in the searchresults.php file near the end like this: $modules->call_hook('search_end', ''); // Call any module functions Notice the function that we just modified in the mod_user.php file is called seller_store_search_end(). This is the name of the module and then the module function name, search_end. So whenever any file uses the searchresults.php file any module that has a search_end function in it will be called and added to the searchresults.php output.

OK, so now that we have the seller store ready to go, let’s add the RSS link. The seller store module output displays in either the showlistings.tpl or showlistings2.tpl, depending on which one you have chosen in your administration. I personally use the showlistings2.tpl myself, so that is the file that I am gong to modify to show the RSS Feed link. So, let’s open the showlistings2.tpl file. This is in your template folder here:
yourclassifiedsite/templates/yourtemplatefolder/showlistings2.tpl
Again, make sure you have a backup and make sure that you use a plain text editor.

You should see the seller store right at the very top of this file. It’s starts with a smarty comment line {* user store display *}. Yea, I know… Duh! OK, so let’s edit in this RSS Feed link. Look for line that has the $storeDescription in it around line 10. It should look like this:
<td>{$storeDescription}</td>
Notice that this is in a table data cell within a table row. So what we want to do is add another table row and another data cell with our link in it. So after the line from above you will see the next line ends the table row like so: </tr>
Make a new line and copy and paste this code below:
{* Modification to add an RSS Feed Link for this seller *}
<tr>
<td align="center">
<img src="{$smarty.const.URL}/templates/{$smarty.const.MAIN_TEMPLATE}/images/rss.png" alt="rss feed icon">  <a href="{$smarty.const.URL}/external.php?owner={$owner}">This store Feed</a>
</td>
</tr>

A couple things to note in my code. First, notice that I added a smarty comment. You should get in the habit of doing this any time that you make your own modifications. It will save your sanity. Secondly, notice that I added align=”center” to my table data, that’s just a personal preference, because I like it centered.

I also used the smarty urls for both the main site and the template folder. I did this mainly for myself in case I were to ever release this modification with something. This would make it work regardless of who installs it, because it would be based on their settings. You can of course hard code your urls if you want to.

Well, there you have it. This will display your seller store as normal, but have an RSS Feed link on the next line after it. Enjoy! Thanks for visiting. Come back again. Don’t forget to consider donating to my blog or buying something from me! Either works for me. :)

-Mike-N-Tosh™

3 Responses to “Add an RSS Feed to the Seller Store”

  1. Get Your Ex Back Says:

    Not that I’m totally impressed, but this is a lot more than I expected for when I stumpled upon a link on Furl telling that the info is awesome. Thanks.

  2. Glenn Pennell Says:

    Hi Mike,

    Great tutorial, will this work with the normal 68 Classifieds (not seller store). Could you have an RSS feed for each category?

    Glenn

  3. Mike-N-Tosh Says:

    Yes, you can add an RSS feed for any category. You wouldn’t need to make any modifications to any “.php” files to do this though. You may want to read my article about using the RSS feed right here in this blog! It will show you how to use the RSS feed for any of the parameters already built in to it.