Drupal search block customizing - drupal

I have my block template block.tpl.php
<div class="block">
<?php print $content ?>
</div>
And I want to change block wrapper for search form
<div class="block search">
<?php print $content ?>
</div>
I'm trying to use block-search.tpl.php but it doesn't work

There is a feature in Drupal - you can override specific template(block-search.tpl.php) in theme when you override general template(block.tpl.php).
Other thing is that probably your cache is not cleared - try
And here you have some nice description how to check other things that could failed.

Related

Bootstrap collapse stops working when switching field type to WYSIWYG

I'm creating a FAQ page on my wordpress site. I am using bootstrap 4.0's collapse component and ACF Pro to build the page.
On the back end, an admin can add questions and answers. The answers are to be hidden on the front end until a user clicks on the question to toggle the answer. Originally the answer field was a text area. All was working great! But when I changed the answer field type to be a WYSIWYG editor, the collapse functionality stopped working altoghether and the answers are not hidden or collapsible. Does anyone know how to solve this issue?
Thanks in advance, code snippet below.
<?php while( have_rows('topic_information') ): the_row();
$question = get_sub_field('question');
$answer = get_sub_field('answer');
$counter++;
?>
<div class="question-btn collapsed" data-toggle="collapse" data-target="#<?php echo $counter; ?>" aria-expanded="false" aria-controls="<?php echo $counter; ?>">
<div class="question">
<p class="question-text">
<?php echo $question; ?>
</p>
<div class="toggle-status"></div>
</div>
<div class="answer">
<p id="<?php echo $counter; ?>" class="collapse" aria-labelledby="headingOne" data-parent="#accordion"><?php echo $answer; ?>
</p>
</div> <!--.answer-->
</div> <!--.question-btn-->
<?php endwhile; ?> <!-- WHILE ( have_rows('topic_information') -->
I've experienced this with bootstrap when the bootstrap.js, bootstrapcdn or bootstrap.min.js is referenced more than once on a page. For me the plugin I was using was also importing or referencing its own bootstrap.js or bootstrap.min.js file which it why it was happening to me.
I would try removing the bootstrap.js or bootstrap.min.js reference from the ACF Pro plugin if possible or try removing it from your project (since your plugin is already referencing it) to see if works.
If that doesn't work you might want to try doing it from javascript since it sounds like the faq is dynamically generated:
bootstrap collapse not working when creating dyanmically
Good luck

wordpress apply_filter values are not coming inline

I am using follwing code in my wordpress custom theme template
<p id="news"> <?php echo apply_filters('the_content',$myNews)?></p>;
And the desired output should be like this
<p id="news"> Herer goes my news content from $myNewsvariable </p>
But i am getting output like this
<p id="news"></p>Here goes my news content from $myNewsvariable
Please tell me how i can fix this
the_content function prints out content by default. So there is no need to do a duplicate echo before apply_filters.
Also you can apply your filter to get_the_content:
<?php echo apply_filters('get_the_content', $myNews); ?>

wordpress custom page template based on a specific <div>

I want to know how to set up a custom page template. My website is based on many different widths. example for some pages I use a div called <div class="content-wrap ninecol clearfix"> but for another page I use <div class="text-centered twelvecol clearfix">.
I need to create a template so that I can easy create new pages based on those templates.
Below is my static html code that Ive done in dreamweaver.
<div class="content-wrap ninecol clearfix"> <!--I want to make a template based on this div so I can just add new text in the future-->
<div class="content">
<h1 class="title">Om oss</h1>
<hr>
<div class="entry-content">
<h4>Vilka är Unified Sweden?</h4>
<p>Vi värnar starkt om vår unika företagskultur och ser den som vårt kraftfullaste
konkurrensmedel. Inom företaget har vi alltid arbetat hårt för att skapa den
stabila grund som vår företagskultur är byggd på. </p>
<p>All personal på Unified Sweden har många års erfarenhet av webbutveckling,
programmering, design och kundservice vilket gör oss unika då alla led inom kundbemötandet
vet exakt vad ni som företag behöver hjälp med.</p>
</div>
</div>
</div>
and this is what I came up with.
<?php
/*
Template Name: Test
*/
?>
<?php get_header(temp); ?>
<?php
// get_template_part( 'loop', 'index' );
?>
<div class="breadcrumbs">
<?php if(function_exists('bcn_display'))
{
bcn_display();
}?>
</div>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
</div><!-- content-wrap -->
</div><!-- #content -->
</div>
</div><!-- .main -->
<?php get_footer(); ?>
Thank you for any kind of help or support.
Are you saying that for each template you want a different style? If yes you need to give different name at div id and then you should edit your style.css
#namediv{ }
to setup custom page template (if i understand your question correctly)
you create your page template in the theme directory which is active
and use the header the way you did
<?php
/*
Template Name: Test
*/
?>
you replace Test by whatever you want to use for the name (this name can have space)
then in the admin, you can select the template to use for the page by going to Admin > Page Attributes > Templates
Your new custom template should appear here
edit (following op comment)
then you could check which template is being use with
is_page_template()
http://codex.wordpress.org/Function_Reference/is_page_template
from within the header.php that would then load a specific css file
side note: you might also want to check the codex page: http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates as well as the dedicated wordpress stackexchange https://wordpress.stackexchange.com/
Template Name : Your page name
*/
you replace Test by whatever you want to use for the name (this name can have space) then in the admin, you can select the template to use for the page by going to Admin > Page Attributes > Templates Your new custom template should appear here

Drupal 7 - Where can I find templates for render() function?

While I was creating my custom template for node, I found out that Drupal adds extra html.
so I changed page.tpl.php like below to test
<div style='height:300px'>
<?php print render($page['content']); ?>
</div>
and then changed node.tpl.php to
hello
the output is:
<div style='height:300px'>
<div class="region region-content">
<div id="block-system-main" class="block block-system">
<div class="content">
hello </div>
</div>
</div>
</div>
where do all those extra tags come from?
I actually expected <div style='height:300px'>hello</div>
drupal_render() can be used to render so called renderable arrays. These are self-contained, they tell render() which theme function/template to use.
Try dpm($page['content']), that should then have a '#theme' key that contains that information.
Nice one with the dpm.
To print the h2 and body you could write something like this in the page.tpl.php.
<?php print render($page['content']['system_main']['nodes'][1]); ?></div> ?>

Wordpress blogcontent not in class

Currently working a html -> wordpress theme and having struggles with blogcontent.
I made a page-blogpost template and a single-blogpost template.
The problem is the following:
In my single-blogpost template I wrote the code:
<p class="blogpost-text"><?php the_content(); ?></p>
Which, I thought should normally put all of the blogpost content INSIDE the "blogpost-text"-class. However this is what happens when I view the code in the browser:
<p class="blogpost-text"></p> -> EMPTY ?
<p>Lorem ipsum... </p> -> (this is the blogpost content text1)
<p></p> -> Enter inside the blogpost content
<p>Lorem ipsum... </p> -> (this is the blogpost content text2)
If there is no special requirement for p tag then use other html tag.
<div class="blogpost-text"><?php the_content(); ?></div>
Please use this:
<p class="blogpost-text"><?php echo get_the_content(); ?></p>
I have tested it. Its works fine.

Resources