printing the smarty file content

i am including template like this:

<div id="comments" > {include file='comm/comm_all.tpl'} </div>

and i would like to echo the comm_all.tpl contents to the html. somthing like that:

<div id="comments" > {include file='comm/comm_all.tpl'} </div> <div id="code_preview" > the code previw is: {include_function file='comm/comm_all.tpl'} </div>

the include function is what i looking for, and it

should take the file content and print "as it is" for example:

<div id="comments" > 1. bla bla the show 2. it`s an array as you guess. </div> <div id="code_preview" > the code previw is: {foreach $array as $i => $v} $i. {$v.content} {/foreach} </div>

-------------Problems Reply------------

If I understand you correctly, what you want to do is not within Smarty, but could be done with a plugin function in PHP.


function include_function($params, $smarty){

$filename = "{$smarty->template_dir}/{$params['file']}";




<div id="comments" >
{include file='comm/comm_all.tpl'}
<div id="code_preview" >
the code previw is:
{include_function file='comm/comm_all.tpl'}

Category:include Views:0 Time:2011-07-21

Related post

  • Perl not printing file contents 2011-08-03

    I'm writing a script in Perl that reads from a file and prints the contents. It's reading the file without errors, but it's not printing the contents. #!/usr/bin/perl use warnings; use strict; use autodie; my $dir = "/home/user/.fluxbox/.notify/notif

  • Python file contents to be read by another python file and print the content 2012-02-02

    python file contents to be read by another python file and print the content taking 2 python files print (content of if any(data): print data validate() random() result: if any(data): print data print data validate() random() is

  • Change a music file so I can print out list of contents of file. 2013-03-09

    how can i print out a list of my music file contents with wma. file type? --------------Solutions------------- Hi, Please refer to the link mentioned below.

  • php: wordwrap text file contents to fit it in letter-size print page ( each line to Pixel width) 2011-09-22

    I want to print simple text file (no style, formatting ) ,such that it fits in letter-size page and any overflow should be wrap to next line etc. wordwrap() php wordwrap function is doing what needed , but I am not sure how much character at maximum

  • Visual Studio: Printing all source files in a solution? 2009-03-25

    Is there a way to print all (*.cs) files in a solution at once, that is, without clicking on each of them and then hitting print? --------------Solutions------------- From what I gather from a similar question asked elsewhere, this "feature" is not b

  • Best-practice for documenting available/required Java properties file contents 2009-04-08

    Is there a well-established approach for documenting Java "properties" file contents, including: specifying the data type/contents expected for a given key specifying whether a key is required for the application to function providing a description o

  • How would you do a search from the unix shell with both constraints on the filename and the file content? 2010-01-11

    Can find perform full-text search? How would you do a search with both some constraints on the filename and the file content? --------------Solutions------------- find -name whatever -exec grep --with-filename you_search_for_it {} \; {} contains the

  • Printing to a file from a list of lists in Python 2010-02-08

    I am trying to print to a file that will look like: 'A' '1' 'B' '2' 'C' '3' Given the code below, however, the result is : ['A'] ['B'] ['C'] This is probably a 'softball' question, but what am I doing wrong here? l1 = ['1'] l2 = ['A'] l3 = ['2'] l4 =

  • How to read file content into a struct line by line in C 2011-02-14

    Here, I am trying to read the contents of a file line by line and create a struct for each line. The problem is when I print the list of words, every single one of them is the last word of the file (which is } in this sample). I believe since line ch

  • Checking for duplicate file (contents) in git? 2011-04-25

    In my 'project/repo' I have two MS Visual Studio projects, one for the main code, and an independent one for tests. I have some files that are common to both (in the copy and paste sense) and I'd like to see / check which ones they are. What is the r

  • List file names based on a filename pattern and file content - GREP? 2011-05-06

    How can I use Grep command to search file name based on a wild card "LMN2011*" listing all files with this as beginning? I want to add another check on those file content. If file content has some thing like LMN20113456 Can I use GREP for this? Grep

  • Read file contents with unknown size 2011-05-08

    I want to process the contents of a config file. The config file could be any size. I am getting a Bus Error, after the program hangs, when I run the following code: FILE *fp; struct stat st; char *buffer; fp = fopen(CONFIG_FILE, "r"); if (fp == NULL

  • print automatically html file with powershell 2011-08-25

    I want to print an html file to the default printer with powershell. So lets say I have the file c:\test.html with the text: <html> <p> hello <b>world</b></p> <html> How could I print test.html to the default print

  • Python: How to read all text file contents in multiple folders and save them into one excel file 2011-09-30

    I am currently working on this task and got stuck. Please give me your advices. The code I am writing below, it returns only the .txt file name from multiple folders, while I would like to print out the content of each .txt file and save in different

  • Joomla print page location file to change the format 2011-11-03

    In joomla 1.5.23 I want to remove the date icon and first horizontal line between title and date.Also there are two horizontal line between date and content where as I need only one line.How can I aligned the logo to the right? Actually I want to kno

  • Cleaning up POSKeyError: 'No blob file' content from Plone site 2011-12-28

    We have an old Plone site with Data.fs and blobstorage which has probably been copied wrongly in some point of the past. portal_catalog rebuild does not run because of POSKeyErrors Module plone.indexer.wrapper, line 59, in __getattr__ Module

  • window.print not printing correctly in Opera, but print preview then file->print works flawlessly; using print css 2012-01-06

    Unlike a few other articles, this is not an issue with window.print() not working in Opera. It does work. Whether I navigate to File->Print or call window.print(), a print dialog box opens. The problem is the output is not correct. Specifically, a

  • Comparing user input to file contents with Java 2012-02-08

    I want to write a java code which reads a file having many sentences for example- Hey how you doing? Hi I am fine. Hello World, Good Morning! The user is asked to enter the first word of sentence as input and the output should be the rest of the sent

  • Reading and printing an entire file in binary mode using C++ 2012-02-09

    a follow up to my previous question (Reading an entire file in binary mode using C++) After reading a jpg file in binary mode, the result of the read operation is always 4 bytes. The code is: FILE *fd = fopen("c:\\Temp\\img.jpg", "rb"); if(fd == NULL

Copyright (C), All Rights Reserved.

processed in 0.405 (s). 11 q(s)