this is my pyro cms code.
{{ images }}
{{ if default == 1 }}
<div><img src='{{ src }}'/>
{{ endif }}
{{ /images }}
this condition is not working when i try to print default value.
{{ images }}
{{ default }}
{{ images }}
i have two images in array. and output is return.
0 1
in array already have a default value 1. but condition is not working.
please help where i made mistake.
thank you.
Related
I have a twig template (home.twig), and I'm using
{{ render(controller('WebsiteUserBundle:Registration:register',{ 'template': 'popup'} )) }}
inside that template to render another template (login.twig), which is used to login the user from a popup.
The problem is that the form_widget isn't rendered, but the form_label is.
This is part of my login template:
<div class="row-fluid">
{{ form_label(form.email, 'Email:')}}
{{ form_widget(form.email, { 'attr': {'class': 'span12'} }) }}
</div>
And by "it's not rendered", I mean that there isn't even an empty div or input next to the label element in the DOM.
Why is this happening?
I had the same issue and was because I had the follow sentence before the form_widget
{{ form_rest(form) }}
Check that the form_rest be after of all your form_widget.
if you get only form_widget without extra params, like this :
{{ form_widget(form.email) }}
do you have more informations or any output ?
I have a "master" layout that has a section: #yield('other-scripts')
I use this master template in another view (especie.blade.php):
#extends('layouts.master')
#include('layouts.editarEspecie')
#section('other-scripts')
{{ HTML::script('js/lightbox.js') }}
#stop
Inside layouts.editarEspecie, #section('other-scripts') is also overwritten:
#section('other-scripts')
{{ HTML::script('js/chosen.jquery.js') }}
{{ HTML::script('js/chosenScriptModal.js') }}
{{ HTML::script('js/scripts.js') }}
#stop
The problem is that #include('layouts.editarEspecie') goes first, so #section('other-scripts') never adds the part inside especie.blade.php.
What can I do so that both part are added and it ends like this?
{{ HTML::script('js/chosen.jquery.js') }}
{{ HTML::script('js/chosenScriptModal.js') }}
{{ HTML::script('js/scripts.js') }}
{{ HTML::script('js/lightbox.js') }}
P.S.: I do this because lightbox.js is always necessary, but chosen.jquery.js, chosenScriptModal.js, scripts.js may not always be needed.
Inside layouts.editarEspecie dont have a "section" - just have this:
{{ HTML::script('js/chosen.jquery.js') }}
{{ HTML::script('js/chosenScriptModal.js') }}
{{ HTML::script('js/scripts.js') }}
Then those 3 lines will always be included.
The thing is, I donĀ“t want those 3 lines to always go inside
layouts.editarEspecie, just when certain conditions are met (not shown
here)
ummmmm.. i know its like the fastest thing ever but you can always PHP if it
<?php
if (condition)
{
?>
{{ script here}}
<?php
}
else
{}
?>
Sorry for lazy explanation but i am sure you get the hint
pyrocms page in Body Editor how to code for display custom fields data. like
i have a image custom field. i write code like.
{{ image:id }}
{{ page:image:id }}
{{ pages:image:id }}
{{ template:image:id }}
{{ custom_fields }}
<img alt="" class="img-custom-responsive img-border" data-pyroimage="true" src="{{ url:site }}files/thumb/{{ image:id }}/310/310/fit" />
{{ /custom_fields }}
i write this code in body Editor But this is not return image id.
How can i get image id on body Editor.
please help.
Thank you.
There is no "id" attribute for the image field type.
Check out the docs on the image field-type to see the available attributes.
Example:
{{ custom_fields }}{{ image:img }}{{ /custom_fields }} // produces a full img tag
{{ custom_fields }}{{ image:filename }}{{ /custom_fields }} // get the filename
Trying to use partials in the Statamic CMS to keep some content areas as DRY as possible.
According to the documentation, I can pass variables to a partial like so:
{{ theme:partial src="sidebar" my_count="2" }}
In my partials/sidebar template, I have the following:
{{ my_count }}
{{ entries:listing folder="projects" }}
I am number {{ my_count }}
{{ /entries:listing }}
However, when the page loads, the variable inside the {{ entries:listing }} tag is not parsed.
2
I am number
I am number
I am number
I am number
I am number
Am I missing a step to get {{ my_count }} to output when called inside the entries tag pair?
NOTE: My ultimate goal is to pass the variable to a parameter, like so:
{{ entries:listing folder="projects" limit="{{ my_count }}" }}
...
{{ /entries:listing }}
The variable won't parse inside of the entries:listing tag pair, but you can use it as a parameter.
This example code works:
partials/temp.html
{{ entries:listing
folder = "blog"
limit = "{ limit }"
}}
{{ title }}
{{ /entries:listing }}
templates/temp.html
{{ theme:partial src="temp" limit="2" }}
Ok, so a long title, but apologies, he only way to describe it without getting the wrong kind of answer.
So, the scenario....
I am creating a site which has a search form of sorts in the header, and therefore on every page. I would like it to retain its previous variables when being used for user convenience, for my convenience I have built the form into the default layout, to save recreating many instances of it.
default.blade.php (Heres the form, with unnecessary markup removed)
{{ Form::open(array('url' => '/search')) }}
{{ Form::select('model', Photo::getAvailableModels(true), $model) }}
{{ Form::select('colour', Photo::getAvailableColours(true), $colour) }}
{{ Form::submit('Go') }}
{{ Form::close() }}
The $model & $colour are variables I am capturing during the post. The problem is, I am getting unset variable errors from Blade on any pages where the user hasn't posted to, so I am literally having to preset them in almost every route or controller across my entire site, just to prevent the errors.
In essence, the system works fine as long as the user is posting, if someone visits the site using a direct link its basically useless.
Obviously I can not have the search form be set to the previously searched results, but that would be bad practice from a usability point of view.
Am I missing something here, surely there has to be a simple solution to this. Thanks for any help.
Create a view composer for your highly used variables:
View::composer(['store.index', 'products.*'], function($view)
{
$model = Input::get('model') ?: 'modelX';
$colour = Input::get('colour') ?: 'colourY';
$view->with('model', $model);
$view->with('colour', $colour);
});
Laravel will send those variables to your views automatically, every time someone hit one of them.
You can put that in your routes file, filters file or, like, me, create a app/composers.php and load by adding
require app_path().'/composers.php';
To your app/start/global.php.
You can check whether variables are set or not with PHP isset():
{{ Form::open(array('url' => '/search')) }}
#if (isset($model) && isset($colour))
{{ Form::select('model', Photo::getAvailableModels(true), $model) }}
{{ Form::select('colour', Photo::getAvailableColours(true), $colour) }}
#else
{{ Form::select('model', Photo::getAvailableModels(true)) }}
{{ Form::select('colour', Photo::getAvailableColours(true)) }}
#endif
{{ Form::submit('Go') }}
{{ Form::close() }}
Or, if your form fields are optional and you need to check separately:
{{ Form::open(array('url' => '/search')) }}
#if (isset($model))
{{ Form::select('model', Photo::getAvailableModels(true), $model) }}
#else
{{ Form::select('model', Photo::getAvailableModels(true)) }}
#endif
#if (isset($colour))
{{ Form::select('colour', Photo::getAvailableColours(true), $colour) }}
#else
{{ Form::select('colour', Photo::getAvailableColours(true)) }}
#endif
{{ Form::submit('Go') }}
{{ Form::close() }}