Hi all,
I would like to pass a number of variables (two URLs to files) from the content part of an article to a template that inserts a sidebar in the article itself.
I know about RT and have used those before but I can not get this to work even with simple [PHP] inserts.
As I see it, I want to insert something like this in my article:
{SETPDFLINK:test.pdf}
And then use this variable inside a .tmpl file associated with this article.
How do I do this?
Send me a message if you want to see the files in action.
Thanks!
Michiel
[SOLVED] Pass a variable from article content to a template?
[SOLVED] Pass a variable from article content to a template?
Last edited by kipara on Tue 6. Jun 2006, 10:32, edited 1 time in total.
Hello kiapara.
I made something in this direction. For transporting of variables i just used the Regular Expressions. Something like index.php?any&p=1
you can strip the varibale off in the then called file ... Template, article ..anyway
This I had in the frontend-render, nevertheless should be good as reptag as well
Juergen
I made something in this direction. For transporting of variables i just used the Regular Expressions. Something like index.php?any&p=1
you can strip the varibale off in the then called file ... Template, article ..anyway
This I had in the frontend-render, nevertheless should be good as reptag as well
Juergen
Thanks Jürgen,
That won't work I think as the variable is not passed on from page to page but 'inside' the page.
Say I type <p>topic blah blah</p> in the article itself, and then I type {link-this-file-in-sidebar:topic.pdf}
This file is then automatically linked-to in a complicated sidebar I pull into the article using a 'display article' template (based on 'sampl.tmpl').
Is this clear? Or do I understand you wrong?
That won't work I think as the variable is not passed on from page to page but 'inside' the page.
Say I type <p>topic blah blah</p> in the article itself, and then I type {link-this-file-in-sidebar:topic.pdf}
This file is then automatically linked-to in a complicated sidebar I pull into the article using a 'display article' template (based on 'sampl.tmpl').
Is this clear? Or do I understand you wrong?
As usual I was looking in the wrong place...
The simple way to do this is to make a new {RT}. I made one that takes a file name and builds a complete sidebar around it. Works for 0, 1 or 2 images and captions. I upload the files by FTP myself as I have yet to work around the file re-naming inside phpwcms (the files NEED to keep their original names)
RT (sample, for one image and caption):
My PHP coding is not the best but this works for me:
Cheers,
Kipara
The simple way to do this is to make a new {RT}. I made one that takes a file name and builds a complete sidebar around it. Works for 0, 1 or 2 images and captions. I upload the files by FTP myself as I have yet to work around the file re-naming inside phpwcms (the files NEED to keep their original names)
RT (sample, for one image and caption):
Code: Select all
{SIDEBAR:image.jpg,Caption,,}
Code: Select all
<?php
// SIDEBAR:alias replacement
$content["all"] = preg_replace('/\{SIDEBAR:(.*?),(.*?),(.*?),(.*?)\}/ie', 'get_sidebar_content("$1","$2","$3","$4");', $content["all"]);
// -------------------------------------------------------------
function get_sidebar_content ($image1, $caption1, $image2, $caption2) {
if ($image1=="") {
$ret = "<div id=\"column\">\n<h2>Contacts</h2>\n<p>Should you need further information please contact your <a href=\"index.php?contacts\">local press office</a></p>\n</div>\n";
return $ret;
}
else {
if ($image2=="") {
$ret = "<div id=\"column\">\n<h2>Download</h2>\n";
$ret .= "<img width=\"186\" alt=\"".$caption1."\" src=\"picture/small/".$image1."\" />\n";
$ret .= "<p>Image HR".$image1."<br />".$caption1."<br />\n";
$ret .= "<a href=\"picture/HRE/HRE".$image1."\" target=\"_blank\">High Resolution JPEG file</a></p>\n";
$ret .= "<h2>Contacts</h2>\n<p>Should you need further information please contact your <a href=\"index.php?contacts\">local press office</a></p>\n</div>\n";
return $ret;
}
else {
$ret = "<div id=\"column\">\n<h2>Download</h2>\n";
$ret .= "<img width=\"186\" alt=\"".$caption1."\" src=\"picture/small/".$image1."\" />\n";
$ret .= "<p>Image HR".$image1."<br />".$caption1."<br />\n";
$ret .= "<a href=\"picture/HRE/HRE".$image1."\" target=\"_blank\">High Resolution JPEG file</a></p>\n";
$ret .= "<img width=\"186\" alt=\"".$caption2."\" src=\"picture/small/".$image2."\" />\n";
$ret .= "<p>Image HR".$image2."<br />".$caption2."<br />\n";
$ret .= "<a href=\"picture/HRE/HRE".$image2."\" target=\"_blank\">High Resolution JPEG file</a></p>\n";
$ret .= "<h2>Contacts</h2>\n<p>Should you need further information please contact your <a href=\"index.php?contacts\">local press office</a></p>\n</div>\n";
return $ret;
}
}
}
?>
Kipara