Sidebar

startup_tutorial_and_checklist:usability_configuration:seo:fields_in_title_and_meta

Placing Field Data into Title and Meta Tags

Within the listing details page you are about to place data placement tags within either the page template or the listing details templates. Within the default design the default page template is:

/main_page/listing_page.tpl

and the listing details templates are the following depending on the edition of the software you have (Classifieds, Auctions or Max):

/main_page/listing_classified.tpl
/main_page/listing_auction.tpl

You can find the full list of tags you can place within any of those templates within the following admin tool page:

PAGES MANAGEMENT > BROWSING LISTINGS > LISTING DISPLAY PAGE (scroll down the page for the full list)

Within that list of tags you'll also see to the right if that tag is found in the listing classified, listing auction or page template attached to that page in the system.

For this tutorial we'll assume you want to display the site wide optional fields 1 and 2 in the title and site wide optional fields 3 and 4 in the meta description. These would be the corresponding field placement tags found for those fields int eh above admin tool page:

{listing field='optional_field_1'}
{listing field='optional_field_2'}
{listing field='optional_field_3'}
{listing field='optional_field_4'}

The following shorthand will work also…we'll use these in our examples:

{$optional_field_1}
{$optional_field_2}
{$optional_field_3}
{$optional_field_4}

So you essentially place those tags where ever you want that data to appear in your template. They are already placed by default within the listing_classified.tpl and listing_auction.tpl templates to make them if you choose to use them. But in this tutorial we'll place them within the listing_page.tpl template where the html head title and meta tags are placed. Below is what we find by default in the listing_page.tpl template:

<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>{module tag='module_title'}</title>
		<meta name="description" content="">

By default we set the title module in the title field. That by default places the title of the listing within the title tag. You have limitless options here but below are a few examples you could use:

<title>{module tag='module_title'} - {$optional_field_1} - {$optional_field_2}</title>

<title>{$optional_field_1} - {module tag='module_title'} - {$optional_field_2}</title>

<title>{$optional_field_1} {$optional_field_2}</title>

<title>{module tag='module_title'} {$optional_field_1} {$optional_field_2}</title>

We would only suggest you use the above if you have a fixed value chosen from a dropdown to place in those fields. That way you know there is no option of insert html corrupting code into those fields. If those fields are open text box or text area fields you would want to attempt to strip those fields of html and limit their length within the title field. You can use smarty code within the template to accomplish this. So using the above as examples you would use something like:

<title>{module tag='module_title'} - {$optional_field_1|strip_tags|truncate:70|escape:'all'} - {$optional_field_2|strip_tags|truncate:70|escape:'all'}</title>

<title>{$optional_field_1|strip_tags|truncate:70|escape:'all'} - {module tag='module_title'} - {$optional_field_2|strip_tags|truncate:70|escape:'all'}</title>

<title>{$optional_field_1|strip_tags|truncate:70|escape:'all'} {$optional_field_2|strip_tags|truncate:70|escape:'all'}</title>

<title>{module tag='module_title'} {$optional_field_1|strip_tags|truncate:70|escape:'all'} {$optional_field_2|strip_tags|truncate:70|escape:'all'}</title>

The same goes for meta tags also. See the examples below:

<meta name="description" content="{$optional_field_3} - {$optional_field_4}">
<meta name="description" content="{$optional_field_3} {$optional_field_4}">
<meta name="description" content="{$optional_field_3|strip_tags|truncate:70|escape:'all'} - {$optional_field_4|strip_tags|truncate:70|escape:'all'}">
<meta name="description" content="{$optional_field_3|strip_tags|truncate:70|escape:'all'} {$optional_field_4|strip_tags|truncate:70|escape:'all'}">

Please note the above are just a few examples using site wide optional fields but note that you can place any available field placement tag within the title and meta tags. Remember that's all tags found in the above mentioned admin tool page. But do note that some tags wouldn't seem feasible (like image placement, links,…etc) and still others contain html that will need to be stripped using smarty code. We've added a few more examples below to illustrate some possibilities:

<code> <title>{module tag='module_title'} - {$optional_field_1} - {$optional_field_2} in {$city_data}, {$state_data} {$zip_data} {$country_data}</title> <meta name="description" content="{$optional_field_1} - {$optional_field_2} in {$city_data}, {$state_data} {$zip_data} {$country_data}"> <code>

Note that you can include the region selection within the title automatically by configuration within the geographic navigation addon but if you feel that's inadequate you can do the above.

Note that you can have more than one version of the listing_page.tpl template. If site wide optional field 1 is only used in one category you could create a category specific version of that template for each category you needed using the category specific template feature described here. So if you only used site wide optional 1 in one category the category specific listing page template for that category could include it. Category specific templates for categories that don't use that field could remove mention of it.

Note that you can place the site wide optional field in any of the templates mentioned above and if it's not in use within that listing or category it will simply be replaced with nothing. So you can place that field placement tag and if not used in that instance it will be replaced with nothing…the tag will not appear.

Note The above allows you to place site wide optional fields in the title of the page for the listing's details. But if you simply wanted the results of site wide optional fields to actually be the title of the listing you can do that also with the automatic title feature explained here in the support wiki

startup_tutorial_and_checklist/usability_configuration/seo/fields_in_title_and_meta.txt · Last modified: 2015/02/19 21:59 by geojames