how to show the code snippet in drupal post or page

I tryed to display php code and html tag in a tuturial.
First simple option is,

Use the tag to post the php code or html code and display in the post
as I have done below


There are nice modules which are useful for showing the code sample in post.

Code Filter

http://drupal.org/project/codefilter

This module provides a simple text format (input filter) that handles and tags so that users can post code without having to worry about manually escaping < and > characters with < and >
—————————–

Syntax highlighter

http://drupal.org/project/syntaxhighlighter

This module integrates the SyntaxHighlighter Javascript Library into Drupal for source code list syntax highlighting within any Drupal contents.
—————————————-

GeSHi Filter for syntax highlighting

http://drupal.org/project/geshifilter

The GeShi Filter module provides a filter for source code syntax highlighting for a wide range of languages.

Source code can be entered with for example ... or…. Starting from version 5.x-2.0 it is also possible to define your own generic and language specific tags (e.g.) or to work with square bracket style tags (e.g. ). Automatically adding line numbers is possible too with for example .

Posted in Drupal, PHP | Tagged , , | Leave a comment

drupal 7 site slogan not printing – core issue – solved

I created custom drupal theme for my project. I checked site slogan and site name is not printing with logo image.

When I checked the $vars variable following value in template.php file

$slogan_text = $vars['site_slogan'];
$site_name_text = $vars['site_name'];

I found that empty.

I added following code in following function in template.php file.


/**
 * Override or insert variables into the page template.
 */
function YOURTHEME_preprocess_page(&$vars) {

// getting site slogen and site name variables

if (variable_get('site_slogan', '')) {
 $slogan_text = variable_get('site_slogan', '');
 }

 if (variable_get('site_name', '')) {
 $site_name_text = variable_get('site_name', '');
 }


 $vars['site_name_and_slogan'] = $site_name_text . ' - ' . $slogan_text;

}

 

If you have already above function then please add inner code in your function.

Posted in Drupal | Tagged , | Leave a comment