How to use conditional placeholder in custom template [wp plugin] - wordpress

I am using event manger plugin.
How to use this code in a custom template file??
{fully_booked}content{/fully_booked}

You have to put your HTML content between the conditional placeholder. For example:
{fully_booked}
<div id="myId">
<p>
There are not tickets available
</p>
</div>
{/fully_booked}
Content will only be displayed if the condition is met, otherwise the whole placeholder will be omitted.
More info in Events Manager Doc
[UPDATED]
You can use it fomr PHP too, but it is a bit different. In the Plugin page you have a tutorial

Related

How to provide a convenient link to next post in Ghost Framework (Blog)

Is there a way to conveniently provide a link to the next post in the Ghost Blogging Platform?
How to do that?
Ideally it would be dynamic. Therefore if I change the title of the next post I would not have to go to the post and manually change it there since it will know the details of the next post has changed.
You can use the {{next_post}} helper to do that. Inside this helper, you can use the usual post attributes, like the url or title.
Here's the implementation from my blog theme:
<div class="next-post">
{{#next_post}}
Next <i class="fa fa-angle-double-right"></i>
{{title}}
{{/next_post}}
</div>
Here's more in the documentation: https://themes.ghost.org/docs/prev_next_post

ACF shortcode for inline css using content editor in wordpress

So this seems to not work on wordpress, any reason why this might be happening, I am using Advanced Custom Fields plugin and every custom field shortcode I have used in my content editor which is executed using the_content(); is working perfectly fine. even shortcodes in <a href=""> tags.
But for some reason this one gets ignored, if I take it out of the style="" and test it, I get the image URL value, but in the background-image: attribute I get no value.
<header class="docs-main" style="background-image: url('[acf field='header-background-image']');">
</header>

Wordpress - Remove auto tags from field content in custom posts type

NOTE: Previous questions on this subject only relate to content entered into the main Wordpress editor window - NOT custom fields in the admin area. The accepted answers do not answer this question.
This question is specific to removing surplus <p> and <br /> tags within custom fields.
Using Wordpress I know it's pretty simple to remove the <br/> and <p> tags from the content entered in the editor:
remove_filter('the_content', 'wpautop');
However, while this deals with content entered in the main post info window, this isn't being applied to markup entered in a 'Types' custom field in a custom post type. There, when content is pasted in, it still gets the auto <p> and <br /> tags.
I can work around this temporarily by altering the core includes/formatting.php file:
function wpautop($pee, $br = 0) {
However, this will get overwritten on future Wordpress upgrades. How can I remove auto <p> and <br/> tags from any content entered in the Wordpress admin area - specifically custom field areas where the remove_filter on the_content has no effect?

Adding custom CSS to Drupal 7 to hide the message

I use my custom block for displaying a flash game at the front page of my Drupal 7 installation, but there is also the annoying message:
<div id="first-time"><p>No front page content has been created yet.</p>
<div class="item-list"><ul><li class="first last">
Add new content</li>
</ul></div></div>
below it and I can't remove it. Is there please a hook for adding custom CSS? In my module I would like to make the #first-time light grey or invisible.
I prefer not to add a blank content just to get rid of that text.
Thank you!
Alex
UPDATE:
I've added the following to my module:
function game_init() {
drupal_set_message('XXX init called XXX');
if (drupal_is_front_page()) {
drupal_add_css('#first-time {color: green;}', 'inline');
}
}
but don't see that CSS-code or XXX string inside my front page.
UPDATE2:
Oh, I had to clear the cache and now it works (the Drupal docs seem to be wrong here - there was written that 'inline' CSS is not cached...)
Hiding the CSS is the WRONG way of doing it. why did you created your content as a Custom Block?
you should create a "Page" and set this page as front page in the Configuration->Site Information.
Whatever. you can also use any of these options but is not recommended.
you can also also add a BlankPage by Adding only the Title(then hiding it in PHP on page.tpl.php)
you can add your css in /templates/themes/bartik.info
you can call drupal_add_css on the _init() hook of your custom module.
Blocks are used to display information in every page(although we can set to display only on certain pages). Say For Example. A Menu, or A Shopping Cart etc.
If you want to add some CSS for a module, you should use drupal_add_css()
Why not simply add this CSS to your theme?

Views is stripping tags from the output

I have a Drupal view which should output a video player using flash. I am trying to output a script that will call the flash film. The problem is that Views applies some sort of filter that strips my <script> tags, the opening and the closing one. I am searching a solution (some setting in views that will disable that filter), but cannot seem to find an answer. Other HTML tags work, but it seems the script tag is being stripped, probably for some security reason.
I have selected the option to rewrite the output of the field and I am using the tags correctly
Views also strips style attributes from my tags. For example:
<h3 style="border-bottom: solid 1px #ffcc99;">Some text here</h3>
appears like this:
<h3>Some text here</h3>
Is there a solution for this? Thank you.
Begin edited
I am pasting below the code I am using in my view.
<div class="bloco-filme">
[title]
<div class="field-imagem">
[field_imagem_fid]
<script type='text/javascript' src='sites/default/files/js/swfobject.js'></script>
<div id='mediaspace[nid]'>Se você estiver visualizando esta mensagem, significa o Flash Player não está instalado em sua máquina. Para assistir ao vídeo é preciso instalar o Flash player</div>
<script type='text/javascript'>
var so = new SWFObject('sites/default/files/plugins/jqplayer/player.swf','mpl','205','undefined','9');
so.addParam('allowfullscreen','true');
so.addParam('allowscriptaccess','always');
so.addParam('wmode','transparent');
so.addVariable('file','[field_video_fid]');
so.addVariable('quality','false');
so.write('mediaspace[nid]');
</script>
[field_video_fid]
</div>
<div class="field-resumo">
<p>[body]</p>
</div>
</div>
Edited again
The code above is beinng posted in my view. I have created a view to handle this. This is the FIELDS area of my view:
Fields
Node: Nid
Node: Título (title, it is in pt-br)
Node: Link "editar" (edit)
Node: Link "apagar" (delete)
Conteúdo: Imagem thumbnail image
Conteúdo: Video URL do arquivo (video file URL)
Node: Corpo (Body)
I have disabled the display of all the fields above and have packed all the code in the Body field. There I selected the option that I want to rewrite the output of the field.
kiamlaluno identified the basic problem, but to solve it, you're going to have to use a field template which will avoid using the filtering system Views uses. Group 42 has a great guide to walk you through the basics of Views theming, so I'll just gloss over those details and talk about your specific case.
First, you need to identify which field you want to rewrite: I believe you're doing that using the Field configuration, but it's not clear which field you are rewriting. I'm going to assume it's the body field. Go through Group 42's guide to create a new template file for the body field in your theme.
In the new template file, use the following code:
<div class="bloco-filme">
<?php print $view->field['title']->render($row) ?>
<div class="field-imagem">
<?php print $view->field['field_imagem_fid']->render($row) ?>
<script type='text/javascript' src='sites/default/files/js/swfobject.js'></script>
<div id="mediaspace<?php print $view->field['nid']->render($row) ?>">Se você estiver visualizando esta mensagem, significa o Flash Player não está instalado em sua máquina. Para assistir ao vídeo é preciso instalar o Flash player</div>
<script type='text/javascript'>
var so = new SWFObject('sites/default/files/plugins/jqplayer/player.swf','mpl','205','undefined','9');
so.addParam('allowfullscreen','true');
so.addParam('allowscriptaccess','always');
so.addParam('wmode','transparent');
so.addVariable('file','<?php print $view->field["field_video_fid"]->render($row) ?>');
so.addVariable('quality','false');
so.write('mediaspace<?php print $view->field["nid"]->render($row) ?>');
</script>
<?php print $view->field['field_video_fid']->render($row) ?>
</div>
<div class="field-resumo">
<p><?php print $output ?></p>
</div>
</div>
Save your new template file, and now the body field will be replaced with the correct output. Just make sure all the fields you've referenced in the template are before the body field within the Fields list when you edit the View.
You can see that this is mostly HTML with a few PHP bits. Code like this:
<?php print $view->field['title']->render($row) ?>
outputs the contents of a field other than current one (i.e. you use this code when you want to reference fields other than Body). It references the same row and finds the value of the field.
And code like this:
<?php print $output ?>
Outputs the value of the current field, in this case, Body.
I don't think the view is causing the issue. kiamlaluno is quite correct that the input format will strip a lot out of your code, unless you alter the input format, however I'm not sure you'll actually be able to achieve what you are trying to do using the body field in any sort of graceful way.
Use views to output the content you need from each node type, but I never use views to determine how this will be displayed (apart from ordering fields etc). I tend to do this either using the display fields option (/admin/content/node-type/[your-node-type]/display) or in the theme. In other words I theme the node (content type) or the field itself.
I would consider looking here - http://drupal.org/node/206980 - to see how to theme individual fields. use the field_ (field name prefix) at the start of a copy of the content-field.tpl.php in your theme folder (you'll find it in the theme folder of your cck folder), and use this to theme the field the way you want it to be presented (using your code above). So, when the view picks it up to display it, it will theme it using your code above.
This, of course, has the added advantage that you don't need to add in any code to the body element of the page, which is not a scalable way to do this at all.
Alternatively, you could write a small module which uses hook_field() (link 1, link 2) to rewrite the field display, but unless you want to be able to customize any of this in the admin area of the site, your best option is probably to theme the field itself as above.
I had nearly exactly this issue (thanks for posting it!), but a few things have changed (obviously) in the three years since this post.
In my case, using Views 3 and D7, I was able to paste all of the relevant swfobject code into a Header or Footer of my view, making sure to use the Text Area type with Full HTML as the text input filter.
No editing of the template.php was necessary. I even used token replacement to provide contextual filter arguments to my movie's flashvars.

Resources