I have created a basic template in Visual Composer which mostly defines a layout of the page. Now I can select this template from "My templates" in VC.
However, what I really need is to call the template from a single_page.php file. Ensuring that end users can't change the layout via VC.
Is there any way how to do so? Via some VC API function or shortcode? Something like [vc_template name="my_custom_layout"]?
Thanks for any help,
Jakub
Have you tried
echo do_shortcode( "[vc_template name='my_custom_layout']", false );
Related
I would like to load pagination module on different module than article. I have found that
components\com_content\views\article\tmpl\default.php contains this:
<?php
if (!empty($this->item->pagination) && $this->item->pagination && $this->item->paginationposition && !$this->item->paginationrelative):
echo $this->item->pagination;
?>
<?php endif; ?>
unfortunately if I put this code for example to my template index file it does not work. Aparently I have to add something more to this.
Could you advice me what other part of the code is needed?
Thank you!
It's a little complicated to wrap your mind around but if you look in the plugins/content folder you will see the pagenavigation plugin. This is the plugin that creates the pagination you see in articles.
THis plugin is triggered by
$results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.article', &$item, &$item->params, $offset));
which you can find in `\components\com_content\views\article (and also archive and the tag view of com_tags). I have no idea why it's not triggered in other components except at some point probably someone thought there wasn't a usecase for it.
To trigger the plugin in another component you would need to add that same event or a different event that basically does what the onContentBeforeDisplay method in the plugin does. If it is your own component I would do it in the same place content and tags do. If you need it in one of the core components you could probably do it by using another event.
I'm doing my first totally custom Drupal 7 theme. I have the page.tpl.php file working fine and have header and footer regions working, until I move this:
<?php print render($page['main_menu']); ?>
into region--header.tpl.php - the menu is no longer generated - the html around the PHP is generated - nav etc. so I know drupal's reading the template file OK.
The same code works fine if it is in page.tpl.php
Any help greatly appreciated.
Main menu available as block. So you can just put him to this region. It's good practice.
Also don't forget to clear drupal/browser cache.
If you define custom variable in preprocess_page() or any other preprocess functions you shouldn't use render function, just use print $main_menu for example.
Also try check this
I am working with a Smarty 3 script and I need to call mybb header and footer templates. I normally just create a .php page and put the eval code directly in it but I can't do that with smarty I have to make a plugin. Is it possible to make a plugin that calls templates from mybb?
The normal code to call mybb templates would be like..
<?php
define('IN_MYBB', 1); require "./global.php";
add_breadcrumb("Title here", "somename.php");
eval("\$html = \"".$templates->get("template_name")."\";");
output_page($html);
?>
I have never worked with Smarty let alone making plugins for this?
If you want to assign anything to variable in PHP using Smarty, you could use fetch() method.
For example in PHP:
$html = $smarty->fetch('template.tpl');
In Smarty template file:
This is template.
And after running it, you will have assigned This is template text to $html variable.
How can I place a default text (hashtag) in the Custom Message?
The textarea is (located in line 643) under jetpack/modules/publicize/ui.php
I tried to put the text in front of $title in various ways, like:
<?php echo "#myhashtag $title"; ?>
or
<?php echo '#myhashtag '.$title; ?>
but it just echoes the text, not the $title.
Any ideas will be greatly appreciated.
You can use the approach of this Wordpress plugin i made (Publicize With Hashtags), which does exactly that. It basically use and action trigger bound to the 'save_post' native event.
If you want to develop your own one you can have a look at my Source Code on the project's GitHub page or in this installation & usage guide I wrote about it.
You can add a filter, like so, to your theme's functions.php or a site-specific plugin:
add_filter( 'wpas_default_prefix', 'add_default_publicize_hashtag_prefix', 10, 4 );
function add_default_publicize_hashtag_prefix() {
$default_tags = '#yourhastaghere ';
return $default_tags;
}
This will add your default hashtag before your title without you needing to hack the WordPress core.
jetpack/modules/publicize/ui.php itself states in its comments:
/**
* Only user facing pieces of Publicize are found here.
*/
You added your hashtag in the textarea which allows admins to enter a custom message (click edit and it will slide down with your hashtag).
As #Yazmin mentioned, the best way to permanently edit the message is using a filter. The filters available are wpas_default_prefix, wpas_default_message, and wpas_default_suffix.
Personally, I had no success using these filters and I'm interested in a working solution to this issue myself.
I want to use search module in my header.tpl file .
In that i used this code
{include file='./modules/blocksearch/blocksearch.tpl'}
But it's not working and by using this code my page gets blank.
Thanks in advance
Here you will find what you are looking for
http://www.ecartservice.net/prestashop-articles/1-4-plugins-revisited-part-1/
It is a great and easy way to call modules directly in template files, without the use of hooks. I tested it in both Prestashop 1.4 and 1.5 and it works.
For Prestashop 1.5, you will need to create 2 extra files in the "override" folder, as described in the link above:
Plugin.php in /override/classes/
FrontController.php in /override/classes/controller/
Then, you will be able to use in the template files the following code:
{plugin module='editorial' hook='displayHome'}
You need to use the hook's name (displayHome) and NOT the alias (home).
You cannot include a module template like this because the PHP code of te module is not called and the template needs it to set some Smarty variables.
The best you can do is to hook the blocksearch module to your header. Here we go :
Navigate to "admin > modules > positions"
Click on "Transplant a module" button
Select "Quick Search Block" for "Module"
Select ""Header of pages / displayHeader" for "Hook into"
Click "Save"
The "Quick Search module" is now hooked to your header.