How to create a new region in omega subtheme? - drupal-7

I am a new in drupal development. I know about Creating region in custom theme.But I want to create a subtheme as base theme of omega. I want to add the new region but not worked I cannot add the blocks in this region?Any one help me?

In your omega subtheme .info file add a new region:
regions[machine_name] = 'Actual Name'
Then clear your cache, go to the subtheme appearance settings, click the "Zone and region configuration" tab, and scroll down to the bottom to find your "unassigned regions". Simply assign it to a zone, configure the options above, and save.
Then add a block to the region in Structure->Blocks and template it appropriately.

First define regions in your theme .info file. See: Structure of the .info file
Then put the relevant template tags in your page.tpl.php file.
For example if you defined the region sidebar in your themes .info file, you would then add: <?php print render($page['sidebar']); ?> to the relevant place in your page.tpl.php.
NOTE: If your theme doesn't have a page.tpl.php file you can copy the default from your base theme, and modify that copy. and do clear the cache.

Related

Reuse a 2sxc DNN module twice with different content in each one

Hi I am trying to use the '_Content - Title only.cshtml' module template for a text heading on my dnn page but wish to use multiple times on same page. Problem is once I select dnn option 'make a copy' and edit text it changes text for each instance of the 'title only' module? I know I can duplicate the '_Content - Title only.cshtml' Razor file but I hoped there might be an easier solution? Thx, Denis
Yes - the problem lies within the DNN copy functionality. It only copies the module "wrapper" but this wrapper still points to the same data - so editing it will edit the shared content-item.
Basically you just want to add another content module (not copy, add), and everything works.

Resize CiViCRM image in Drupal views

How to resize civicrm images(uploaded via webform) in Drupal views.
The images are getting displayed but the width and height are of the size when they upload images..
2 solutions come to mind
Use css to give each image a max-width property. This will make images appear correctly, but won't save bandwidth as the full image will be downloaded and scaled client-side.
Use a drupal module such as Image Resize Filter
If you need more advanced resizing / image transformation options, you can create a custom template file for the image URL field and use drupal image style (admin/config/media/image-styles) to define the required conversion.
As CiviCRM is protecting the files (we don't have the files urls in the database since 4.4.4 ?), you need to use imagecache_external (didn't manage to make image_style_url work). The drawback of this module is that the image is duplicated in drupal.
Anyway, to make this work :
install imagecache_external, go to the configuration page (http://YOUR_SITE/admin/config/media/imagecache_external) and add YOUR_SITE to the white list
create a style http://YOUR_SITE/admin/config/media/image-styles/add
configure the view as needed and add the CiviCRM Image URL field
Edit the view -> Advanced -> Information
Find the file name corresponding to the field you want to customize and create the file with this file name in YOUR_THEME/templates/
Paste the following code (replace 'thumbnail' with the style name you have created) :
<?php
if ($row->{$field->field_alias} != '') {
print theme('imagecache_external', array(
'path' => $row->{$field->field_alias},
'style_name'=> 'thumbnail'));
}
?>
back to Edit the view -> Advanced -> Information -> Rescan templates file and then save the view.
This didn't quite work on a drupal 7 / CiviCRM 5.10+ system (don't know if it still works on earlier).
To make it work put this in the template file:
<?php
$path = $field->render($row);
if (!empty($path)) {
print theme('imagecache_external', array(
'path' => $path,
'style_name'=> 'thumbnail'));
}
?>

Drupal 7 : How to show specific block in a particular view

I want to display particular block on view page. I have added list to show specific view in a particular block as <viewpagename>, but it is not working. How can I show a particular block on a particular view page in Drupal 7?
Long time I didn't touch Drupal, however, if I remember right, after you choose a path for your view, you can add that path to the settings of the block.
so if the view is available on /view-page, add to the block setting "view-page" in the "include" section.
There is a block_views module made specifically for this reason I believe. It's in beta but works rather nicely for Drupal 7:
https://drupal.org/project/block_views
Cheers,
-cs

Drupal 7 Template Suggestions not working

If I create a region in the info file like:
regions[footer_panel] = Footer panel
then render this in the page template (page.tpl.php):
print render($page['footer_panel']);
then try and create an overide template to work with (as described in documentation):
block--footer_panel.tpl.php
finally print some static text in that file, Im not getting any results. Please could someone advise?
Caches have been flushed and block.tpl is in the templates folder.
Try adding the generic block.tpl.php to the theme as well. Sometimes it won't pick up the block template suggestions if that file isn't present first. Be sure to clear the cache again.
I'm also assuming that you have a block inserted into that region. If you do not have a block designated to show in that region creating a template file will do nothing. You need to create a block and then create the template file based on that blocks name/ID not the region name.

Drupal 7 not using the template suggestion

I have added the following to my template.php file, in the [themename]_preprocess_page function:
<?php
if ($variables['is_front'])
{
$variables['theme_hook_suggestions'] = array();
$variables['theme_hook_suggestions'][] = 'page__index';
}
if (isset($variables['node'])) {
// If the node type is "blog" the template suggestion will be "page--blog.tpl.php".
$variables['theme_hook_suggestions'][] = 'page__'. str_replace('_', '--', $variables['node']->type);
}
If I run a var_dump on the $variables array, I can see that, on my front page, the 'theme_hook_suggestions' is set to only use 'page__index'. I have a file named 'page--index.tpl.php'. Drupal still uses page.tpl.php.
I also commented out the code above, and renamed the file to 'page--front.tpl.php' and it still used page.tpl.php. I clear the caches after every change.
What am I missing?
Edit: To help clarify, I want to override the entire design of the page for the front - no columns or sidebars, different graphics, different backgrounds on some of the div's, etc. I don't want to override the 'node--' template files (yet).
In the end, I need to have a static front page with a different design than the rest of the site, then a custom node template for each content type.
I worked with the awesome folks on the #drupal IRC channel and found the issue. Not sure if this is a bug in the code or on purpose - but you cannot use the word 'index' for those theme suggestions. I changed the content type's name to 'homepage' and voila!

Resources