Call Module in tpl file in prestashop - php

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.

Related

How to add(include) elementor created page in theme file 404.php

I created a page using elementor(named as: 'Error-page'), currently using linoor theme. What I want is to load this 'Error-page' via theme's default 404.php file (NOT using any plugin). Should I just type in 'include Error-page.php' in 404.php file to make it work?
Meta: My goal is to show my custom error page which I created using elementor(named as: Error-page) when invalid url is typed. One way of doing it is using plugin(I prefer not to do this for the time being), 2nd way could be somehow including this custom page in theme's default 404.php file
Note: Im new to wordpress
after thinking about your question, i have 2 solutions for you:
1. if you do not have code knowledge
This way is simple and safer, but have limits than other way - it's not using your template but redirect viewer to your template page. Any way, the same result
Build the 404 template with Elementor and publish it
Open your theme's 404.php file
In the very first top of the template file **(below <?php tag) paste this code:
wp_redirect( '/your-template-slug' );
exit;
Save it and you're done
2. If you have basic code knowledge:
This way is a litle complex, but it alow you to using not for 404 file - but other templates (archive, categories...)
Install "Anywhere Elementor" plugin
Build the 404 template as you do with Elementor
Get your template php shortcode
Edit the theme's 404.php file to echo out your template
In case you need more detail guide, i have record a step by step guide video here

Wordpress Visual composer - Call template from php file

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 );

Custom Page Template VS Plugin VS Shortcode refer to function

I need to create a form that will be called many times through application .
below is the steps i did :
1- Create a form.php page and place it in my child theme folder.
C:\wamp\www\test\wp-content\themes\designfolio-child
i wrote the below code at the top of the page
<?php /* Template Name: Hercal Template */ ?>
and then i write my form code.
2-This page calls another PHP files and Jquery file , i place those file in
C:\wamp\www\test
3- I create a wordpress page and select a template option 'Hercal Template' ,
The page run now ,form loaded and working fine but i have some issue that i need to understand.
1-What about security , is it secure to place files and database connection to test folder directly ?
2-How can i call my form inside other pages ?
3-the above steps enables me to create a template page , so what is the difference between template page , plugin , short code that refer a function ???
I mean :
when i create a plugin , i can call it anywhere by using function name.
when i create a function,place it into wp-content and create shortcode for it , i can call it anywhere by using shortcode .
so what is the difference between them , i have conflict between (page template,plugin,shortcode).
Thanks
You should use shortcode to display form.
if you will use template than you can't put extra content/design for multiple places.
if you will use function than you have to call that in your page or you need to physically edit template file.
if you will use your form as shortcode than you can access/call it anywhere in your page/post/custom post and place it on anywhere between the div, paragraph etc.
Even you can access it on php file as well
I suggest you to use short code

Theming and layout in yii framework

I am a newbie in Yii Framework and creating a CRM which is module based.
Using different tutorials I am able to create my own theme, but now I am stucked at one point.
In my theme, the upper <nav> and left <nav> remains the same throughout the app, until user is logged in. That's why I made it a part of my main.php, but in the login page there are no buttons to show, just simple login form with 2 textfields.
How can I implement this form in my application using custom themes?
I have tried to define a layout in that particular action but not succeeded. Any help would be appreciated.
Using a custom layout for your view is the right way to go.
You can either set the layout in the controller action or in the view.
$this->layout = "//layouts/mylayout";
Note that the default layouts column1.php and column2.php also use the main.php layout file.
Try this step by step :
Create New theme
You can create a new theme and add this to the directory
Application_Root/themes.
Look at the themes/classic directory to get an an idea of the structure of the directory.
The important file (at this stage) is :-
Application_Root/themes/views/layouts/main.php
Customise your theme contents
Copy the css, image, js files etc to the correct directory and change the main.php file to your liking. For example, if your main.php says
<link href="css/mystyle.css" rel="stylesheet">
Then you will have a file
Application_Root/css/mystyle.css
Create the content placeholder.
Somewhere in your main.php, there will be a placeholder for dynamic text, which is specified by.
<?php echo $content; ?>
Tell yii to use the theme.
Change the file Application_Root/protected/config/main.php by adding the following line just before the last line (containing the closing bracket).
'theme'=>'surveyhub'
Create the layout placeholders.
Create an HTML segment that will be written into the $contents portion of main.php. Call it for example one_column.php. The file path will therefore be Application_Root/themes/views/layouts/one_column.php In that file, where you want the dynamic text to be placed, create a placeholder.
<?php echo $content; ?>
Tell Yii to use the layout.
In the file Application_Root/protected/components/Controller.php, add or modify the layout variable to read :
public $layout='//layouts/one_column.php';
Refresh the page

How to theme Ubercart Checkout Complete page

I want to theme the page /cart/checkout/complete
I already saw the settings in admin/store/settings/checkout/settings, but they are not enough.
I want to add some HTML i.e. add a print button at the top of the page.
I would like to have a .tpl.php file to use as template, or otherwise, using an alternate checkout page, how to insert the texts defined in checkout settings.
I tried to make a uc_cart_complete_sale.tpl.php but it isn't called.
Thank you in advance.
According to the Template Suggestion documentation you can provide a custom page.tpl.php for absolutely any path, so a template file with the following name would override page.tpl.php for the path cart/checkout/complete:
page--cart--checkout--complete.tpl.php
Be sure to clear Drupal's cache once you've create the file so the changes are picked up in the theme registry.
After hard work, i found the template page.
It is:
page--cart--checkout--complete.tpl.php
remember to clear the cache
firstly, you should probably check this page: admin/store/settings/checkout/edit/messages
there you can customize a header for the message displayed when the checkout completes.
other than that, you can implement some functions to alter this page. from a short look in the ubercart api maybe this function will do: my_module_checkout_complete() in this link the guy says it worked
another function that should work is theme_uc_cart_complete_sale
there are other options, such as in your template.php check if this is /checkout/complete and do whatever you want. like this:
if (arg(0) == 'cart' && arg(1) == 'checkout' && arg(2) == 'complete')
and than redirect to your page. anyway, there are plenty of ways to accomplish this, but just naming a file 'uc_cart_complete_sale.tpl.php' won't work. sorry...
In D6 at least, you can theme the message by overriding theme_uc_cart_complete_sale() - so if that's what you're after, theme the message by overriding that in your theme (for example, function mytheme_uc_cart_complete_sale($message, $order) {}

Categories