I think the answer might be obvious but I can't seem to figure it out.
How do I render a view I've created in Views 2 (Drupal) in a page-pagename.tpl.file? My thought was that it would be some sort of PHP snippet but I can't find documentation about it.
Any thoughts that might steer me in the right direction.
The solution is here:
http://views-help.doc.logrus.com/help/views/embed
Also "function" can be replaced with "print" and the additional param brackets can be removed.
So it will look like this:
$name = "yourviewnamegoeshere";
print views_embed_view($name, $display_id = 'default');
Related
I have continued my voyage into creating a extremely simple template engine.
Because I wanted to add logic to my template I eventually got back to the point that I allowed PHP tags into my code which I enabled by evalling the code.
Maybe not the best solution but when looking at the WordPress templates I noticed that the idea itself may not be that bad.
But now there still is one small problem left.
And that is that I want to translate the generated code.
But it has been evalled already. Hence parsed.
I thought of solving this problem by using ob_get_contents().
But this brought one more question and in case of errors it shows a white screen. (memory usage etc.)
Plus it still did not take away the problem of eval that it parsed the contents when evalled.
In short the class logic is:
Loading template files
Adding the contents
Compiling the template
Eval the code (but unfortunately also displaying the code)
Translate the code so I can translate the code parsed by a PHP script
I would love something like:
$code = eval('?>'.$tpl.'<?php');
$code = translate($code);
WriteCache($code);
SetDocumentHeader();
echo $code;
Would anyone know how to achieve this?
Thanks in advance!
$code = eval($tpl);
Check this out.
I am looking for some help with jFormer.
The way my site works a form cannot submit to the same place it was built,
yet looking at the demo code it seems that this is how it has to work?
Is this true?
No guarantees as I am unable to test it myself, but you could try:
$contactForm = new JFormer('contactForm', array('action' => 'my_page.php'));
Items added into the array passed to the JFormer constructor are supposed to be added as attributes to the form tag from what I can see in the code. See https://github.com/kirkouimet/jformer/blob/master/source/development/php/JFormer.php
Update
Actually it looks like I was looking at the incorrect class as they have two classes in the JForm.php file when you would expect there to only be the actual JFormer class in there. They have a JFormElement class at the top of the file! Still I cannot readily see if it might still work or not.
The documentation is lack lustre and the inline comments are worse.
I've written the question in symfony forum, but got no result. Of course I know that people may be busy or unavailable so I can't have my answer right away. But I really needs this fast, so I posted here too. If this is not permitted somehow, please just close the question. Thanks.
Originally posted here:
http://forum.symfony-project.org/viewtopic.php?f=22&t=31537
Hi,
I have some question regarding using zend pagination in zend lucene. Checked the old forum, and found this: forum.symfony-project.org/viewtopic.php?f=21&t=27342&p=103440&hilit=zend+pagination&sid=1cdc305c262c6b3cf79fdeef25761f34#p103440
But I need some additional feature for that. I've tried the code in the post above, and it works. But how do we implement it in view?
Checking zend documentation, i create a view file in /web/view/scripts/pagination.php
with the code for the file found here:
framework.zend.com/manual/1.10/en/zend.paginator.usage.html
With some modification for $this->url() to become link_to()
Then, the code in action looks like this:
$pager = Zend_Paginator::factory($query->execute()->getData());
$pager->setItemCountPerPage(3);
$pager->setCurrentPageNumber($request->getParameter('page', 1));
$pager->setDefaultScrollingStyle('Sliding');
Zend_View_Helper_PaginationControl::setDefaultViewPartial('_pagination.php');
$this->pager = $pager;
And in view:
<?php echo $pager ?>
The problem is, of course, is this the right thing to do?
Then, how can I get the current URL and modify its parameter in view? For zend, as I understands it, it's something like $this->url(array('page', 5)). Anyway to get this done in symfony?
Thanks before.
I've also check SO and get this:
stackoverflow.com/questions/2002648/is-there-a-symfony-helper-for-getting-the-current-action-url-and-changing-one-or
But I can't access $sf_request in the pagination.php mentioned above. I think it's because the pagination.php access Zend's front controller. And the strangest thing is, I can acess the default helper like UrlHelper (tried url_for and link_to - it works).
Ps. Sorry for the links in bold - can't post more than 1 link now.
View scripts usually have a .phtml extension, not .php, that won't matter, but just so you know.
Try changing
$this->pager = $pager;
To
$this->view->pager = $pager;
I cannot seem to figure out where to set the trusted_dir variable in Smarty 3. Now anytime I use a {insert name="func_name" script="thescript"} I get the error "missing script file".
Does anyone out there know how to allow this? $smarty->security is set to false.
Thank you.
EDIT: As of the posting of this question, this functionality has not been added to Smarty 3 yet, but a Smarty admin has assured me he will get onto adding the functionality ASAP. (http://www.smarty.net/forums/viewtopic.php?p=65549), so we should see it soon.
EDIT 2 The functionality has now been added to Smarty 3 and works as in Smarty 2! :-)
http://www.smarty.net/manual/en/variable.trusted.dir.php
It basically says that you have to enable security to access it.
To set the trusted_dir you would do something similiar to this:
$Smarty->trusted_dir = array(
'my_first_dir',
'my_second_dir/my_third_dir'
);
which would allow scripts from my_first_dir and my_third_dir (which is located within my_second_dir).
I am using Jumi to include a number of PHP scripts on Joomla! articles and it works great. The problem I am having is with passing variables (in the form of $_GET parameters) to a PHP script.
Lets say I have a script "index.php" and I wish to pass the $_GET[] parameter "var" with the value of "10". This would normally be accomplished by pointing to: index.php?var=10. How do "emulate" this functionality with Jumi? I was hoping it would be as simple as:
{jumi [directory/index.php] [var=10]}
The above syntax however is not correct.
Any input would be appreciated.
-- Nicholas
After some trial and error and guidance from the official Joomla! forums I did solve my problem. Rather than passing a true $_GET[] parameter you can pass a $jumi array and reference that.
I wanted to avoid having to rewrite much of my script so what I did was the following.
1) Make the Jumi call like this:
{jumi [directory/index.php] [value]}
2) In index.php:
if(isset($jumi[0]))
{
$_GET['PARAM_YOU_WANT_SET'] = $jumi[0];
}
This is a very simple example of a quick and easy way to emulate passing a $_GET[] parameter to a script using Jumi. This approach saved me a great deal of time because I didn't have to rewrite my controller.
-- Nicholas
This is an old thread I know but there is something that some people might want to know.
If you are wanting to use Jumi with extra parameters in a Module then Nicholas' tip won't work but there is a way to do it.
There is a "Code written" section of the module and a "Source of code" section.
Put the url/path to the file in the "Source of code" section and then define your variables in the "Code written" section...it will pass the variable to the source file before executing so it will do what is desired.