Combo Page title

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

Hi Guys,

I'm using the "combo page" generator to display products in categories - seen here: http://freestylepools.com.au/products.php

The pertinent code is:

// load records from 'products_listing'
list($products_listingRecords, $products_listingMetaData) = getRecords(array(
'tableName' => 'products_listing',
'loadUploads' => true,
'allowSearch' => false,
));

// load variations
$variationRecords = mysql_select('variations');
$variationProductNumToRecords = array_groupBy($variationRecords, 'products_listingNum', true);


// 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']];
}
else{
$productsListsRecords = $products_listingRecords;
}

However, google sees http://freestylepools.com.au/products.php and http://freestylepools.com.au/products.php?category=5 as different pages, and I therefore have to change the page title.

How can I capture the link selected (ie. the ?category=5) and create a variable such as $title to use in the head code?  And I guess I will have to have it default to $title = '' initially as nothing is selected?

Cheers,

Tim (toledoh.com.au)

Any thoughts on this guys?

Cheers,

Tim (toledoh.com.au)

By Mikey - September 17, 2014

Howdy Tim,

I haven't messed with the combo page feature what so ever - so I can really help in that area, but what I've been doing is creating a single and multi section - which all the data of both section editors is listed on. The single section editor manages the page exterior elements that need to remain constant, I then load my multi section inside the single (using 6 per page, with pagination), so it appears as a single page with pagination and I have a lot of control over my page and what I wish to display. Basically it's the same principal... just more of a manual process, but once you have one page built you can roll them out fairly fast.

Wish I could help you with your actual question.

Zicky

haha - Thanks Zicky!  There's many ways to skin a cat huh!

Cheers,

Tim (toledoh.com.au)

By Codee - September 19, 2014

If I'm understanding the goal properly, what about something like this in the header:

<title><?php if ($productsRecord['title']): ?> - <?php echo $productsRecord['title'] ?><?php endif ?> -  <?php if ($productsRecord['category']): ?><?php echo $productsRecord['category'] ?> pool products<?php endif ?>- Freestyle Pool Products for Sale</title> 

Thanks Equinox.  However no cigar.

I've attached a sample file (it's a bit messy - sorry).  I guess I need to call the query from the URL somehow... and if there is no query, then default to something else.

ie.

$cat = "Products Page",

Get query from URL (ie.  products.php?category=2) if available.  If so, then $cat="URL-QUERY:label Page"

<title>?php echo $cat</title>

Cheers,

Tim (toledoh.com.au)
Attachments:

sample.php 11K

Hi itools - any ideas on how to achieve this?

Cheers,

Tim (toledoh.com.au)

Thanks Greg.

I'm getting the error: Notice: Undefined offset: 0 in /home/freestyl/public_html/products.php on line 43

Cheers,

Tim (toledoh.com.au)

Hi Tim,

It could be that as you're grouping the items by their category number that the key 0 doesn't exist in the array. Try using this method instead:

  // $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']; 
        break;
      }
    }
  }else{
    $productsListsRecords = $products_listingRecords;
  }

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

Thanks!

Greg

Greg

Greg Thomas







PHP Programmer - interactivetools.com