Loading...
 
Skip to main content

Custom Share Module 0.1dev

Features / Usability

Features / Usability


Adding a new template to Tiki

posts: 96 Romania

Hi. How can I add a new smarty template to Tikiwiki? I need to add one to tiki-download_file.php. Actually I did, but it only works if I comment out the

header("Content-type: $type");

(snip)

} else {
echo "$content";
}


part. I know what it does but I don't know how to make it work with a template. Any help?

posts: 63 United Kingdom

Templates are assigned and displaid through SMARTY

Firstly, oif you edit that header information out, you'll need to provide it somewhere else to make the downloads actually happen. Which I'll assume you've already figured out.

An alternative method would be to create - whatever it is you're trying to display between the click and the download - as a new PHP and tpl combination which you edit into the file-galleries instead of tiki-download file, then you can show whatever you need to show there, which can included the necessary link to the file download or a meta-redirect to it etc.

Is that what ytou were after, there follows a short tutorial on calling templates, which I expect is not the answer to your question, but I already wrote it, so lets leave it be.

The proper method is to assign the contents of your template to the "mid" DIV of the tiki layout. then display the tiki.tpl, which will include the mid DIV thereby including your template in the middle of the page based on your configured layout.

the command is
$smarty->assign('mid', 'template_file.tpl'); $smarty->display("tiki.tpl");

which occurs inside the PHP file AFTER all the processing of the data for the page / error checking etc. takes place.

If you wanted to use your template INSTEAD of the tiki tpl - like the error.tpl file is displaid. You can call it directly using the command
$smarty->display("template_file.tpl");
which will override all the layout in tiki.tpl, unless you copy into your template.

The path and naming convention for templates is to place the template file in the /templates/ folder and the template file should be named the same as the PHP file.

Hope that helps 😊

RW


posts: 96 Romania

Well this is what I have inside the tiki-download_file.php on the last line (header content stuff removed)

$smarty->assign('mid','tiki-download_file.tpl');
$smarty->display("tiki.tpl");

?>

The tiki-download_file.tpl is placed inside the templates folder so this displays the template just fine, but this only happens without the

header("Content-type: $type");

// Added by Jenolan  31/8/2003 /////////////////////////////////////////////
// File galleries should always be attachments (files) not inline (textual)
header( "Content-Disposition: attachment; filename=\"$file\"" );
//header( "Content-Disposition: inline; filename=$file" );

if( $info["path"] )
{
	header("Content-Length: ". filesize( $fgal_use_dir.$info["path"] ) );
}
else
{
	header("Content-Length: ". $info[ "filesize" ] );
}

////////////////////////////////////////////////////////////////////////////
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: public");
if($info["path"]) {
  readfile($fgal_use_dir.$info["path"]);
} else {
  echo "$content";
}


part.

What I need to know is where do I add that stuff to make it work and still have a template?


Upcoming Events

1)  18 Jul 2024 14:00 GMT-0000
Tiki Roundtable Meeting
2)  15 Aug 2024 14:00 GMT-0000
Tiki Roundtable Meeting
3)  19 Sep 2024 14:00 GMT-0000
Tiki Roundtable Meeting
4) 
Tiki birthday
5)  17 Oct 2024 14:00 GMT-0000
Tiki Roundtable Meeting
6)  21 Nov 2024 14:00 GMT-0000
Tiki Roundtable Meeting
7)  19 Dec 2024 14:00 GMT-0000
Tiki Roundtable Meeting