I need to put into my twig template file, in wordpress, a shortcode about my gravityform.
I read this and I've coded following lines
{% filter shortcodes %}
[gravityform id="1" title="false" description="false"][/gravityform]
{% endfilter %}
Now I see all raw html output and not my form in home page. There is any way to process gravity form short code with twig?
Thanks
Related
I want to display the upc in product page with opencart 3. How do I do that?
I added the below code into my template file /catalog/view/theme/default/template/product/product.twig,but it doesn't work.
{% if upc %}
{{ upc }}
{% endif %}
Please do not forget to backup these files first.
You have to add upc as a variable to the controller first and then echo it in the template.
in order to do that:
first edit controller file:
/catalog/controller/product/product.php
and search for
$data['model'] = $product_info['model'];
after that add:
$data['upc'] = $product_info['upc'];
and save the file.
After that your code in template file that you mentioned will work.
ps: by this approach you lose these changes if you update opencart.A better approach would be to make an ocmod extension for it.
I am kinda a newbie at Wordpress.
I've looked a lot on StackOverflow for a solution for this problem but none worked for me.
I'm using Timber and ACF.
Here's the situation: I've made 4 custom post_type ( News, Products, Services and Places ). I've created a custom page for the news. (page-news.twig )
In my page.php file I've added a custom query like this:
global $paged;
if (!isset($paged) || !$paged) {
$paged = 1;
}
$context = Timber::get_context();
$post = new TimberPost();
$context['post'] = $post;
$args = array(
'post_type' => 'news',
'posts_per_page' => 3,
'paged' => $paged,
'page' => $paged
);
$context['news'] = new Timber\PostQuery($args);
So I've set a maximum of posts for page, which is 3, and In my .twig file:
{% for single_news in news %}
{% include['news.twig', single_news] %}
{% endfor %}
{% if news.pagination.prev %}
Prev
{% endif %}
{% if news.pagination.next %}
Next
{% endif %}
When I go to the news page, there are 3 posts per page ( correct ) and it displays me the Next anchor which is correct.
The problem is that the link brings me to /news/page/2 that doesn't exists and gives me 404 error. I've tried many solutions like the pre_get_posts and none worked for me.
Pagination only works on archive pages, but not on singular pages. See The WordPress Template Hierarchy for what counts as an archive page.
This means that you can’t use page.php as your template file for displaying your news posts. You have two possibilities here:
You can use archive.php, or even archive-news.php if your Custom Post Type for news is named news.
If you’d use the default post type post for your news section, you could select the page where you want to display your posts archive. The template file to display your posts archive would then be home.php.
If you go for the first option, you need to make sure that when you register your post type (either through register_post_type() or a plugin), you set the public option to true and that you set has_archive to true as well.
The problem with archive pages is that now you can’t use some editing functionalities that you normally have with pages. For an archive, you can’t set a title or add content with the editor like you’re used for pages. But if you use ACF, you can set up an options page where you add a select for your «Page for News». Name it page_for_news and then, in your template file, you can select the proper post that Timber should use on the archive page with
$post = new Timber\Post( get_field( 'page_for_news', 'option' ) );
This method practically replicates option 2 for Custom Post Types.
Also, a hint about your news post include in Twig:
{% for single_news in news %}
{% include['news.twig', single_news] %}
{% endfor %}
If you do this, then Twig will try to find a news.twig template as well as a template named after single_news. But single_news is not a string here, but an instance of Timber\Post. So that doesn’t help you. You can use the following instead:
{% for single_news in news %}
{% include 'news.twig' %}
{% endfor %}
I'm in the process of building a site in October CMS that uses a slash page. The splash page is only supposed to show to non cookied users the first time that they visit the site. I am controlling this part via a component in a plugin called splash. Here is my onRun() function:
public function onRun()
{
$key = 'shownsplash';
if(!Session::has($key) || !Cookie::get($key))
{
$this->page['showsplash'] = true;
Cookie::queue('shownsplash',true);
Session::put($key,true);
$resp = NULL;
}
}
In my main page layout called 'default' I want to conditionally load the splash page template called 'splash' using the following:
{% if showsplash %}
{{ loadpage('splash') }}
{% else %}
Regular page template
{% endif %}
Except that I'm not sure how to load a page conditionally. One additional requirement is that the splash page takes the url http://www.example.com and not any subsequent pages. Can anyone point out how to do this?
in octobercms cms/page are hit by url , the url set in the config section and are bound to a layout. so for me page are more 'routing' object than html content holder.
In fact partials ARE html content holder
So if i had to do the same thing as you mean i would use partial and page.
a page with url="/" and two partials, one for the regular page and one for the splash.
bind your plugin component to the page not the layout
{% if showsplash %}
{% partial 'home/splash.htm' %}
{% else %}
{% partial 'home/regular.html' %}
{% endif %}
I think partial are exactly what to use in this kind of conditional stuff.
generaly think of
layout as website structuration
page mainly for routing
partial for html content
I have this include file with following code. I assume I can used wordpress is_single() to twig template file. When I tried to accessing the detail page of a wordpress post this display the word Nothing.
Even though I have a post name foo post and I did also create a rev_slider named foo post.
{% if wp.is_single('foo post') %}
{{ wp.do_shortcode('[rev_slider foo post]')|raw }}
{% else %}
Nothing
{% endif %}
Am I doing this correctly?
Your code is correct, but just be sure you have the right post title or the right post name is wp.is_single()
Is there way to use diffrent themes for two (or more) forms on the same page.
I've 2 forms and I'd like to use theme "X" for first form and theme "Y" for second form.
You need to declare your theme before displaying your form.
You should try :
{% form_theme form 'ThemeX.html.twig' %}
{{ form(formX) }}
{% form_theme form 'ThemeY.html.twig' %}
{{ form(formY) }}
If that doesn't work (ie. second form theme declaration doesn't overwrite the first one), just use a separate template for your second form and insert it in your parent template using an include.
Try [http://symfony.com/doc/current/cookbook/form/form_customization.html#child-forms](this page) of symfony doc for more information