Combo Page title

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

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)

By gregThomas - September 23, 2014 - edited: September 23, 2014

Hi Tim,

What about doing something like this:

<?php
  
  require_once("_app_init.php");
  
  $categoryTitle = "";

  // error checking - check required plugins installed and activated
  if (!@$GLOBALS['SIMPLECART_PLUGIN']) {
    die("You must activate the SimpleCart plugin before you can access this page.");
  }

  // load record from 'pages'
  list($pagesRecords, $pagesMetaData) = getRecords(array(
    'tableName'   => 'pages',
    'where'       => "`num` = '9'", //PAGE CONTENT http://freestylepools.com.au/cmsAdmin/admin.php?menu=pages
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $pagesRecord = @$pagesRecords[0]; // get first record
  if (!$pagesRecord) { dieWith404("Record not found!"); } // show error message if no record found


// 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']];
  if($productsListsRecords){
    $categoryTitle = "Category - ".$productsListsRecords[0]['category:label']; 
  }
}else{
  $productsListsRecords = $products_listingRecords;
}

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

So if a category is detected, it looks as if you're filtering the current records on it. So at that point we can grab the category title from the first record from that list and store it in the variable $categoryTitle.

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

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 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