Mosets Tree uses listing names as page titles. This article shows how you can make a simple core modification to Mosets Tree's source codes to use one or more custom fields data in your listing title.

 

Note: The steps below involve modifying a core Mosets Tree file. These modifications will be removed and overwritten when you upgrade Mosets Tree. This should only be performed if you're experienced with Joomla and PHP.

 

  1. Edit this file: /components/com_mtree/mtree.php
  2. Look for the following codes near line 2353:
    setTitle(JText::sprintf( 'COM_MTREE_PAGE_TITLE_VIEWLINK', $link->link_name ), null, $link_id);
    
  3. Replace the line above with the following codes:
    // $cf_ids_for_title holds an array of fields ID to used in listing
    // title. ID 1 refers to listing name.
    $cf_ids_for_title = array(1, 41, 54);
    

// $title_parameters contains an array of parameters to be passed to // JText::sprintf. Edit the line below to control how and where to // output each custom fields. $title_parameters[] = 'Your custom title - %s - %s - %s';

foreach($cf_ids_for_title AS $cf_id ) { $tmp = $fields->getFieldById($cf_id); if( !is_null($tmp) ) { $title_parameters[] = $tmp->getValue(); } }

// Output the title setTitle( call_user_func_array(array('JText','sprintf'), $title_parameters ));

  • $cf_ids_for_title holds an array of custom fields ID that you want to use in your title. In the example above, we have the listing name (ID: 1) and two custom fields, represented by ID 41 and 54. Remove and add additional field IDs as needed here.
  • The first assignment for $title_parameters controls how to output/arrange your static text and custom field values. Each of the %s specifier represents your field value. You can refer to PHP's sprintf documentation for more information.

This instruction is based on Mosets Tree 3.5.6, but it should work on any recent versions of Mosets Tree from version 2.1 up.

 

Recent Posts