WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Bakery Shop »
  • Different template for view item
  • Print
Pages: [1]   Go Down

Author Topic: Different template for view item  (Read 7266 times)

daydreamer

  • Guest
Different template for view item
« on: July 11, 2013, 02:11:04 PM »
Is it possible to set a different template for the view_item.php to make it different from the template in the page settings?
Logged

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Different template for view item
« Reply #1 on: July 11, 2013, 02:19:00 PM »
No, the view.php (loading view_item.php) is actually loaded by the already loaded template.

The bakery item detail page has a special defined variable (ITEM_ID)
You can manipulate your template simply by using something like:

Code: (untested) [Select]
<?php
if ( defined('ITEM_ID')) {
  include (
'index2.php');
  return;
}

Just put this in top of your template index.php.
This way bakery detail pages will use index2.php as template.
Logged
Dev4me - WebsiteBaker modules - WBhelp.org

daydreamer

  • Guest
Re: Different template for view item
« Reply #2 on: July 11, 2013, 02:42:03 PM »
Thanks Rudd,

How would I call the item title in the index2.php?
Logged

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Different template for view item
« Reply #3 on: July 11, 2013, 02:58:44 PM »
Just treat index2.php the same as any other templates/..../index.php
Basically it is a second template in the same template directory.

You could use the Simple pagehead snippet to use the correct titles.
http://www.bakery-shop.ch/#simplepagehead
Logged
Dev4me - WebsiteBaker modules - WBhelp.org

daydreamer

  • Guest
Re: Different template for view item
« Reply #4 on: July 11, 2013, 03:00:23 PM »
Thanks, I mean show the item title in my index2.php template
Logged

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Different template for view item
« Reply #5 on: July 11, 2013, 03:09:56 PM »
That is what the snippet does.
It creates some standard headers, including <title>Your Bakery itemtitle</title>.
It will also use the short-description field in your bakerypage to fill the meta description tag..
Logged
Dev4me - WebsiteBaker modules - WBhelp.org

daydreamer

  • Guest
Re: Different template for view item
« Reply #6 on: July 11, 2013, 03:26:34 PM »
I can call the item ID with
Code: [Select]
<?php echo ITEM_ID; ?> but not the item title as these don't work
Code: [Select]
<?php echo ITEM_TITLE; ?>
Code: [Select]
<?php echo TITLE; ?>
Logged

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Different template for view item
« Reply #7 on: July 11, 2013, 03:31:43 PM »
No, remember your template index(2).php is loaded before any page_content is loaded.
So the template will never be able to have content or page specific variables when it is being loaded.

The snippet actually does this (the hard way) for you.
It knows about bakery/news/topics etc.. and will find the title before the content requested.
Logged
Dev4me - WebsiteBaker modules - WBhelp.org

daydreamer

  • Guest
Re: Different template for view item
« Reply #8 on: July 11, 2013, 03:35:13 PM »
So there is no way of calling the item title direct in my index2.php
Logged

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Different template for view item
« Reply #9 on: July 11, 2013, 03:43:11 PM »
No, not without a call to the database.. (or using the snippet)

A quick oneliner query would be:
Code: [Select]
<?php
$item_title 
= $database->get_one("SELECT `title` FROM ".TABLE_PREFIX."mod_bakery_items WHERE `item_id` = '".ITEM_ID."'");
echo 
$item_title;

Does that help?
Logged
Dev4me - WebsiteBaker modules - WBhelp.org

daydreamer

  • Guest
Re: Different template for view item
« Reply #10 on: July 11, 2013, 03:44:26 PM »
Great thanks Rudd, I am using the simple page head snippet but it's still not working how I am trying to do it
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Bakery Shop »
  • Different template for view item
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2