Combo Page title

15 posts by 4 authors in: Forums > CMS Builder
Last Post: September 25, 2014   (RSS)

By Toledoh - September 24, 2014

The error has gone, but there is still no title showing for the selected category...

Cheers,

Tim (toledoh.com.au)

By gregThomas - September 24, 2014

Hi Tim,

I'm not sure what structure the outputted data is in, could you add the following showme(); so I can see what's being returned?

  if($productsListsRecords){
    $categoryTitle = "Category - ".$productsListsRecords[0]['category:label'];
  }
  showme($productsListsRecords);
  exit;

Once this code is added, you should find that an array is output on the page when you select a category. If you could post what's output in this thread, then I can work out what's causing the error.

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By gregThomas - September 25, 2014

Hey Tim,

I had another look at my code, and I'd missed adding echo for the category title field:


// get the list of categories as array wherein the array key is the category value, and array value is the category label
// $productCategoriesValuesToLabels will be used for the left category list
$productCategoriesValuesToLabels = array_combine(array_pluck($products_listingRecords, 'category'), array_pluck($products_listingRecords, 'category:label'));

// $productsListsRecords will be used for the right sub-list
$productsListsRecords = array();
if (@$_REQUEST['category']){
  $productsListsRecords = array_groupBy($products_listingRecords, 'category', true);
  $productsListsRecords = @$productsListsRecords[$_REQUEST['category']];
  if($productsListsRecords){
    foreach($productsListsRecords as $record){
      $categoryTitle = "Category - ".$record['category:label']; 
    }
  }
}else{
  $productsListsRecords = $products_listingRecords;
}

?><!DOCTYPE html>
<html>
<head> 
<title>A title <?php if(@$categoryTitle){ echo $categoryTitle; } ?></title>

Once this is added, you should find the title will display.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By Toledoh - September 25, 2014

Thanks Greg - perfect!

Cheers,

Tim (toledoh.com.au)