Different template for view item

daydreamer

Great thanks Rudd, I am using the simple page head snippet but it's still not working how I am trying to do it

Ruud

No, not without a call to the database.. (or using the snippet)

A quick oneliner query would be:
<?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?
[url=https://dev4me.com/modules-snippets/]Dev4me - WebsiteBaker modules[/url] - [url=https://wbhelp.org/]WBhelp.org[/url]

daydreamer

So there is no way of calling the item title direct in my index2.php

Ruud

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.
[url=https://dev4me.com/modules-snippets/]Dev4me - WebsiteBaker modules[/url] - [url=https://wbhelp.org/]WBhelp.org[/url]

daydreamer

I can call the item ID with <?php echo ITEM_ID?> but not the item title as these don't work
<?php echo ITEM_TITLE?> <?php echo TITLE?>

Ruud

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..
[url=https://dev4me.com/modules-snippets/]Dev4me - WebsiteBaker modules[/url] - [url=https://wbhelp.org/]WBhelp.org[/url]

daydreamer

Thanks, I mean show the item title in my index2.php template

Ruud

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
[url=https://dev4me.com/modules-snippets/]Dev4me - WebsiteBaker modules[/url] - [url=https://wbhelp.org/]WBhelp.org[/url]

daydreamer

Thanks Rudd,

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

Ruud

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.
[url=https://dev4me.com/modules-snippets/]Dev4me - WebsiteBaker modules[/url] - [url=https://wbhelp.org/]WBhelp.org[/url]

daydreamer

Is it possible to set a different template for the view_item.php to make it different from the template in the page settings?