User Tools

Site Tools


Sidebar

tutorials:design_adv:examples:category_specific_content_in_listing_details_page

Category Specific Content in the Listing Display Page

This tutorial is for advanced users of the software who have html and Smarty code experience. Do not attempt unless you have a firm grasp of each and the ability to debug the changes you make if you run into a problem. Support cannot help with your php, Smarty or html code changes like the ones you would make below. PHP, Smarty or html tutoring is beyond the scope of support we can supply.

You can display content within your listing details page that would only display within listings attached to a specific category. You can easily do this by using Smarty code to check the current category id and choose to display specific content or not based on that category. The Smarty variables $category_id and $parent_categories are available by default within the listing details page so you can easily use them like the code below.

	<!-- # START AUTOMOBILES CATEGORY BANNER GADGET -->
	{if $category_id==15||$parent_categories.15==15}
		<div class="content_box">
			<div class="row_even">
				{* If in category 15 or a sub-category of category 15 (automobiles),
					display the gadgets/automobile_banners.tpl sub-template *}
				{include file="gadgets/automobile_banners.tpl"}
			</div>
		</div>
		<br />
	{/if}
	<!-- # END AUTOMOBILES CATEGORY BANNER GADGET -->

	<!-- # START MORTGAGE CALCULATOR GADGET -->
	{if $category_id==16||$parent_categories.16==16}
		<div class="content_box">
			<div class="row_even">
				{* If in category 16 or a sub-category of category 16 (real estate),
					display the gadgets/mortgage_calculator.tpl sub-template *}
				{include file="gadgets/mortgage_calculator.tpl"}
			</div>
		</div>
		<br />
	{/if}
	<!-- # END MORTGAGE CALCULATOR GADGET -->

The above "gadget code" may already be in your listing_auction.tpl and listing_classified.tpl templates if you upgraded from versions previous to v7.1 when the default design was changed in the software. You'll find the files included above in the /main_page/gadgets directory of your custom template set. If they are not there you can always copy them from the default template set to your custom template set and use them.

As you can have many levels of categories you should also use the $parent_categories variable to check to see if the current category is a subcategory of the category you wish to display the category specific code within.

The above code by default checks for category id 15 and it's parent category id's in one loop and category id 16 and it's parents in the other. Those are just example category id's. To customize for a category in your site you only need the category id for the category you wish to have your gadget code or smarty code in general appear in. To get that category id you only need to go into the CATEGORIES > CATEGORY SETUP admin tool on your site and you will find the category id for each category next to the category name.

To emphasize the point changes like these are beyond the scope of support that we provide through our support staff. If ours default template works and your custom template doesn't you're beyond support our support staff can provide. If you need help from Geodesic you would need to purchase developer time through sales or consult with an external developer familiar with html and Smarty code.

tutorials/design_adv/examples/category_specific_content_in_listing_details_page.txt · Last modified: 2014/09/25 16:55 (external edit)