Variables inside a file inserted with {{file::php-file}}
Hello,
Can somebody tell me how to use insert-tags (like {{user::lastname}}) from inside a .php-file used in a custom-html module through {{file::.php-file}}? It would be easy if you could nest them, like {{file::.php-file?lastname={{user::lastname}}}}, but this doesn't work. What is the proper method to access this information?
Thanks a lot!
Re: Variables inside a file inserted with {{file::php-file}}
Hmm, try like this:
Code:
{{file::.php-file?lastname=<?php echo $this->replaceInsertTags('{{user::lastname}}'); ?>}}
and don't forget to write the {{}} on your own as some OS seem to put hidden chars between the brackets when copying :)
Re: Variables inside a file inserted with {{file::php-file}}
Thank you Toflar, your tip solved my problem. You cannot however, use php-tags inside Custom-HTML modules. But this doesn't really matter.
Re: Variables inside a file inserted with {{file::php-file}}
Hi,
Does anyone know if it's possible to have a tag within a tag?
I'm pulling a random image from an OSCommerce database using a custom script but would like to be able to crop this using the image {{image::*} tag.
Was hoping to be able to do something like {{image::{{file::randomimage.php}}?width=200&mode= crop}}
With the randomimage.php outputting a basic url.
Cheers
Re: Variables inside a file inserted with {{file::php-file}}
@alewar - I believe you just need to go into Settings and add an "Allowed HTML tag" of <?php>
@vinchenzison - My hunch is that this will not work. I did a quick test with a replacement tag within another and it doesn't parse properly. Are you getting any kind of output?
Re: Variables inside a file inserted with {{file::php-file}}
The only output that gets printed on screen is "?width=200&mode=crop}}"
The {{image::{{file::featuredproduct.php}} renders as [img][/img] in html
I also tried adding an insert tag into the php file to see if it was read by contao but it doesn't
Re: Variables inside a file inserted with {{file::php-file}}
I think the best solution is to have all the output generated in the php file. You could always borrow the code that crops the photos. Or, just do something like this to faux-crop the images in css:
Code:
<div class="randoms">
[img]somewhere/image.jpg[/img]
</div>
img.thePhoto {
width: 200px;
}
div.randoms {
width: 200px;
height: 200px;
overflow: none;
}
This is all theoretical, untested and from the top of my head.
Re: Variables inside a file inserted with {{file::php-file}}
Thanks for that.
My mistake though, when I said crop, I actually meant resize to 200px width.
Re: Variables inside a file inserted with {{file::php-file}}
Since you don't need to crop, I'd just re-size the photo with css. In my opinion, this is perfectly acceptable. It's even more acceptable if you are taking a small photo (around 400 or 600px) and changing it to 200px. The browser renders css resizes best when they are a multiple of the original. So, it is best to take a 600px photo and display it at 200px, instead of 180px.
Hopefully this makes sense.
Re: Variables inside a file inserted with {{file::php-file}}
Or use the following code within your template:
Code:
[img]<?php echo $this->getImage('path/to/original.jpg', $width, $height, $mode); ?>[/img]
Both $width or $height are optional but there has to be at least one of them ;)
E.g. you want to resize your image to a height of 150px and keep the proportions:
Code:
$this->getImage('mypic.jpg', null, 150);