On my node page I have the comment form that I've stylised in CSS, the problem is that when I submit this form and the form throw an error all my css disapear, I think this is my whole wrapper who disapear (a div that I set in the wrapper template is gone)
Also the comment block go to the bottom of the page, just before the footer
Here is my wrapper, for the comment I don't do something special it's just the default one
<div id="comments" class="<?php print $classes; ?>"<?php print $attributes; ?>>
<?php if ($content['comments'] && $node->type != 'forum'): ?>
<?php print render($title_prefix); ?>
<h2><?php print t('Avis de nos clients'); ?></h2>
<?php print render($title_suffix); ?>
<?php endif; ?>
<?php print render($content['comments']); ?>
<?php if ($content['comment_form']): ?>
<h2 class="title comment-form"><?php print t('Add new comment'); ?></h2>
<?php print render($content['comment_form']); ?>
<?php endif; ?>
</div>
What can I do ?
Related
i m new to Drupal 7 and in this forum, please be nice :)
I m trying to customize a bit the drupal module "On the web" (that display facebook and youtube link button). This module work great but I would like to to modify the position of the social images provided by this module inside a sub theme of Zen. I could be nice to put it at the left-top the header region.
As it says in the documentation I :
1)
Place the following code in the template.php file in your theme, and replace 'mytheme' with the name of your theme:
/**
* Overrides theme_on_the_web_image().
*/
function mytheme_on_the_web_image($variables) {
return $variables['service'];
}
2) I add this line : <div id="myidtomodifythecssafter"> <?php print $service; ?></div> in the page.tpl.php like following :
<?php if ($site_name || $site_slogan): ?>
<div id="name-and-slogan">
<div id="myidtomodifythecssafter"> <?php print $service; ?></div>
<?php if ($site_name): ?>
<?php if ($title): ?>
<div id="site-name"><strong>
<span><?php print $site_name; ?></span>
</strong></div>
<?php else: /* Use h1 when the content title is empty */ ?>
<h1 id="site-name">
<span><?php print $site_name; ?></span>
</h1>
<?php endif; ?>
<?php endif; ?>
<?php if ($site_slogan): ?>
<div id="site-slogan"><?php print $site_slogan; ?></div>
<?php endif; ?>
</div><!-- /#name-and-slogan -->
<?php endif; ?>
3) I cleared the cache
but then the module images don't appear and i got this error in the front page :
Notice: Undefined variable: service in include()
i don't understand, what did I miss ?
Ok after reading the module code :
The function zhongdao_on_the_web_image is for theming the rendering of your anchor tags. Not really what you want here, so you can remove it.
This module create a block (under admin > structure > bloc) that you can position anywhere in your theme regions, then up to you to style it differently with CSS.
But if you want to render the block content another solution is this one :
https://www.drupal.org/node/26502
Wich will translate to something like this :
<?php if ($site_name || $site_slogan): ?>
<div id="name-and-slogan">
<div id="myidtomodifythecssafter">
<?php
$block = module_invoke('on_the_web', 'block_view', 0 /* might want to change depending of your block*/);
print render($block['content']);
?>
</div>
<?php if ($site_name): ?>
<?php if ($title): ?>
<div id="site-name"><strong>
<span><?php print $site_name; ?></span>
</strong></div>
<?php else: /* Use h1 when the content title is empty */ ?>
<h1 id="site-name">
<span><?php print $site_name; ?></span>
</h1>
<?php endif; ?>
<?php endif; ?>
<?php if ($site_slogan): ?>
<div id="site-slogan"><?php print $site_slogan; ?></div>
<?php endif; ?>
</div><!-- /#name-and-slogan -->
<?php endif; ?>
I override block using these technic https://www.drupal.org/node/1089656.
<div id="<?php print $block_html_id; ?>" class="footer-links-regions <?php print $classes; ?> clearfix"<?php print $attributes; ?>>
<div class="g4_20 tgfull">
<?php print render($title_prefix); ?>
<?php if ($block->subject): ?>
<h3<?php print $title_attributes; ?>><?php print $block->subject ?></h3>
<?php endif;?>
<?php print render($title_suffix); ?>
</div>
<!-- CONTENT -->
<div class="g16_20 tgfull mhidden" <?php print $content_attributes; ?> >
<?php print $content ?>
</div>
</div>
Then I added custom link via admin and Custom URL (Link display). I realized that I can see this link inside content (I mean that this link is added to $content). I would like to handle this link and real content separately.
I have a signifiantly big problem up there.
I'm trying to design my search restult page on WordPress, but if it comes that the search find a page with the keyword I just entered, it display the entire page instead of the title();
My code
<?php
/**
* The template for displaying search results pages.
*
* #package miller
*/
get_header(); ?>
<section id="primary" class="content-area">
<main id="int_top_main" class="internal blue_top" style="min-height:80px;">
<div class="wrapper">
<h2 class="page_title uppercase"><span class="parent_page">Search results</h2>
<div id="infinite_blue_top_bar"></div>
</div>
</main><!-- #main -->
<div id="int_content_main" class="internal">
<div class="wrapper physician_headline">
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>
<?php else : ?>
<h2><?php _e( 'Nothing Found', 'miller' ); ?></h2>
<div class="page-content">
<?php if ( is_search() ) : ?>
<p><?php _e( 'Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'miller' ); ?></p>
<?php else : ?>
<p><?php _e( 'It seems we can’t find what you’re looking for. Perhaps searching can help.', 'miller' ); ?></p>
<?php endif; ?>
</div><!-- .page-content -->
<?php endif; ?>
</div>
</div>
</section><!-- #primary -->
<?php get_footer(); ?>
If it finds nothing, it will go into the else: but if it do finds something they display all the pages (fullpage) of what it finds out there.
It should only display the_title(); but no..
Even if I completly destruct the search.php file it stills automaticly goes to the "suggested" page.
First time I am getting this kind of thing and I do not know how to solve it :(
It's calling for the post before the title, which is why it pulls for the full post.
Try:
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_title(); ?>
<?php endwhile; ?>
<?php else : ?>
basically I have my site setup to display the title of each page/post in the header of my theme. I also have it setup to display the name of an author on my author pages(I did this using a conditional). The problem I'm having is that the name of the author is echoed for the number of posts the author has written and I only want it to echo once. Is there a way I can do this? I realize that its doing this because the_author has to be in a loop(I have a loop in my header to do this). Is there anyway to be able to display the_author outside of the loop?
My site is http://www.imagineitstudios.com . you can see what I'm talking about if you click on the "Posted by Abel" link on the first post of the home page
Thanks for your help.
Here's my code:
<div id="title">
<?php //Check to see if this is an author page ?>
<?php if(is_author()): ?>
<?php while (have_posts()) : the_post(); ?><?php //Creat a mini loop to display the author ?>
<h1><?php the_author();?></h1>
<?php endwhile;?><?php //End of Mini Loop ?>
<?php else :?>
<h1><?php the_title();?></h1>
<?php endif ;?>
</div>
You can use the following code:
<div id="title">
<?php //Check to see if this is an author page ?>
<?php if(is_author()): ?>
<?php
if(get_query_var('author_name')) :
$curauth = get_userdatabylogin(get_query_var('author_name')); ?>
<?php else :
$curauth = get_userdata(get_query_var('author')); ?>
<h1><?php echo $curauth->first_name; ?> <?php echo $curauth->last_name; ?></h1>
<?php endif; ?>
<?php else :?>
<h1><?php the_title();?></h1>
<?php endif ;?>
</div>
I have nodes being displayed as 'promoted to homepage'. The nodes body can contain basic html which is fine for that nodes page but when not for the homepage. Is there any way to modify this to strip any html tags?
Thanks,
Jonesy
The common way to handle this would be to just replace the default home page with a view from the Views module.
Just create a view to list nodes (title/body/post date/whatever), filter by "promote to front page", and check the "strip html" checkbox for the body field.
You can handle this in the theme template. In your theme folder, create or edit node.tpl.php. What it will need to look like will depend on what specifically your node template contains, but with the default template it would be something like this:
<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
<?php print $user_picture; ?>
<?php print render($title_prefix); ?>
<?php if (!$page): ?>
<h2<?php print $title_attributes; ?>><?php print $node_title; ?></h2>
<?php endif; ?>
<?php print render($title_suffix); ?>
<?php if ($display_submitted || !empty($content['links']['terms'])): ?>
<div class="meta">
<?php if ($display_submitted): ?>
<span class="submitted">
<?php
print t('Submitted by !username on !datetime',
array('!username' => $name, '!datetime' => $date));
?>
</span>
<?php endif; ?>
<?php if (!empty($content['links']['terms'])): ?>
<div class="terms terms-inline"><?php print render($content['links']['terms']); ?></div>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="content"<?php print $content_attributes; ?>>
<?php
// We hide the comments and links now so that we can render them later.
hide($content['comments']);
hide($content['links']);
if ($is_front) {
print strip_tags(render($content));
} else {
print render($content);
}
?>
</div>
<?php print render($content['links']); ?>
<?php print render($content['comments']); ?>
</div>
Note, I haven't tested this at all, but if your theme is using the default node template (there is no node.tpl.php in your theme), then you should be able to just drop this in.
The key line is:
if ($is_front) {
print strip_tags(render($content));
} else {
print render($content);
}