I am trying to add more variables than only the $body,$css,... to a mimemail-message.tpl.php template
preprocess_mimemail_message(&$variables)
lets me add custom vars, but what I want is to be able to pass the values when I'm calling drupal_mail to this template.
Thanks
Alternatively it can be done as follows:
template_preprocess_mimemail_message(&$variables) {
$variables['test_var'] = 'some text';
}
And in template use it like this:
<?php print render($test_var); ?>
Related
I am working on CakePHP 2.7. I have to show some static menu on every page. Since, the menu contains lot of sub menus, I want to keep them in a separate file navigation.ctp and show them on default.ctp
I tried extend and elements but none of them give expected result.
Note : This is not dynamic menu and I am not fetching them from database.
Place your navigation.ctp inside app/View/Elements/
Then, inside your default.ctp, include the element as follows:
<?= $this->element('navigation'); ?>
Note that if you need any variables within the element, you may need to pass them through inside an array as a second parameter, such as:
<?= $this->element('navigation', array(
"varible_name" => "variable_value"
)); ?>
I'm using ngtagsinput (http://mbenford.github.io/ngTagsInput/) to add highlight functionality to my app. I can't figure out how dynamically add an id for each tag as its being created. I will be using this id to edit the styling of each tag item after it has been created. I saw the demo about custom templates, but this only works if you pre-define the array of tags. I'm a newb to Angular which is probably the issue... Any hints?
You can add the id using an on-tag-added handler. I made a very simple logic that appends the number of tags as id, but you can do whatever you want.
$scope.onTagAdded = function($tag) {
var index = $scope.tags.indexOf($tag);
$scope.tags[index].id = $scope.tags.length;
};
And in the HTML:
<tags-input ng-model="tags" on-tag-added="onTagAdded($tag)"></tags-input>
You can then use the appended id in your custom template if needed. See this Plunker.
I have tried this line to add class in cakephp form button, but class is not showing in html
<?= $this->Form->button(__('Login',['class'=>'login-btn'])); ?>
How can I add class in button ?
I think your example doesn't work, because the __() Call shouldn't include the array for the options of the button. Please try the following:
<?= $this->Form->button(__('Login'),['class'=>'login-btn']); ?>
Have a try on this below:
<?php echo $this->Form->button('Login',['class'=>'login-btn']); ?>
A good reference here: Creating input elements
Update
__() is for internalization. Using this will look in to your localization file and output it's corresponding translation. In your case, you include the options inside __() which I think it will cause an error but if it didn't, it will look for it's translated version and also this means ['class'=>'login-btn'] is not considered as an option anymore.
it has to be inside an array : try this
<?= $this->Form->button(__('Login'),array('class'=>'login-btn')); ?>
How can I go about overiding CakePHP's code without creating it manually myself? I'm attempting to customise the getCrumbList function.
The lastClass option is applying a class to the 'li' tag sucesfully, but I'd also like to remove the link/ ahref altogether for the last tag.
Function generating crumbs
echo $this->Html->getCrumbList(array('class' => 'breadcrumb', 'lastClass' => 'active'), 'Home');
Output of getCrumbList
<ul class="breadcrumb"><li class="first">Home</li><li>Scheduler</li><li class="active">Downloaded Playlists</li></ul>
Simple solution - You dont include the URL in addCrumb. Doh!
How to generate 'a href="javascript:void(0)"' like link in CakePHP?
I make an application, the content will insert into the editor textarea when user click a list of image. I add a class to these images and write some code in the javascript file. Everything is going well.
But the link of the image is a URL address, but not 'href="javascript:void(0)' like URL. Anyone could tell me how to make it in CakePHP?
Thanks in advance!
<?php
echo $this->Html->link(
'/path/to/image/',
'javascript:void(0)'
);
?>
You can either set a path to the image or use the Html helper to generate the image tag code. The second parameter will set the href.
Don't believe there is any dynamic way, however when you are creating your form element you can set it in the options array 'href' => 'javascript:void(0)'