Unable to add a new region to sub theme - drupal

So I have a Bartik sub-theme that I am using for my website. Now the idea is to add a custom region to this theme. I am following the process described below:
Add custom region to subtheme.info file like : region['custom_region'] = Custom Region
Add to subtheme's page.tpl.php page:
This does not work and the custom region does not appear when I check for it.
I did the same for the Bartik theme (that is the default provided theme) and it works fine, meaning the custom region appears where it ought to be.
So what's fishy here? : p
Thanks guys!

You shouldn't need the apostrophes. Also, you should define the region as "regions" - so try this in your .info file:
regions[custom_region] = Custom Region
Good luck! :-)

In page.tpl.php page insert:
<?php if ($page['custom_region']): ?>
<div id="custom_region">
<?php print render($page['custom_region']); ?>
</div>
<?php endif; ?>
And Flush all caches

Related

Remove post and comment box in WordPress

I'm designing a website using WordPress. I want to know how to remove the post and comment boxes which is available by default in WordPress...and also I want to know how to add plugin's in that static page
First, create page with name "Home", insert shortcode of plugin or anything you want.
Second, go to Apperance, choose Customize. At Static Front Page, tick A static page radio button, choose "Home" from dropdown list Front page. Save.
In order to remove comments yoy must select the "Screen options" in the post editor (it's an option located at top-right on the screen) and check the Comments checkbox. Then at the editor's bottom you'll find a box with a checkbox to disable comments.
If you're working in Wordpress.com you cannot add plugin's for free. This is for security reasons. You must install Worpress in your own server to do that.
Ok, as per your comments on main question, I understand you want to remove posts and comment box on public facing page, not in WP-Admin panel.
I am giving you an overview of how you can proceed.
If you are using default TwentyThirteen thee then just remove this part from single.php
<?php /* The loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php twentythirteen_post_nav(); ?>
<?php comments_template(); ?>
<?php endwhile; ?>
This will remove post and comments template.
However I will recommend you to use custom page templates rather :
http://codex.wordpress.org/Page_Templates
Here you'll find way to add custom page templates. There you can remove posts and comments :-)

Drupal 7 Custom theme and custom module

I know drupal a bit.
I am creating a custom theme and defined a region in my themename.info as
regions[search] = Search Bar
And added the below code to my page.tpl.php
<div id="search" class="search_box">
<?php if ($page['search']): ?>
<?php print render($page['search']); ?>
<?php endif; ?>
</div>
And I enabled search form via Block administration, so everything is fine now.
But, I want to create my custom search module. Please provide me some sample code, so that I can understand.
In explanation, I want to create a hook menu and function which can print what I want and also how can I enable the function to be printed on the region.
Thanks all.
In Drupal each piece of content that can be placed into a region is called a "block". So instead you want to create a Custom Block. Here's a guide, http://fourkitchens.com/blog/2012/07/18/building-custom-blocks-drupal-7.
https://drupal.org/node/1074360, Here is the Drupal module creation tutorial, the guide "generating block content" will be helpful for you.

wordpress custom pre-fixed templates

I want to create a page template that has a pre-fixed css. Lets say I name it page-sevencol.php then I know that the content will have a fixed width and a specific style and so on. My pages have different layouts thats why I need to create these kind of templates.
Is it possible? if so how? Ive looked in the wp codex and it does not seem to have the answer. Please take a minute to help me.
Thank you!
you seem to need just a limited set of templates. The question is: do you want to apply them automatically? Basically, there are two techniques to apply a template to a page (or post or custom post, etc.) in WordPress.
First method: using the template naming convention to get the template automatically applied to a page (or post) with the same name.
In this case, you create a page page-mynewpage.php and this template will automatically get applied to your page named /mynewpage/.
Second method: you create a template by creating a page (let's say : template1.php) and declaring it as a template with a comment at the top of the page:
/**
* Template Name: Template1
*
*/
This template will now be selectable inside the admin of WordPress to be applied to any page:
So if A) you only need a limited set of templates & B) are ok to select them on a per-page basis in the admin, this is your solution. You would just need to create as many pages as you need templates, not forgetting to include the comments that declare them as templates and using a different name each time.
If you need your templates to be applied dynamically, then we need more info about the logic to use for select each template...
EDIT : That is it, Abel (just read your comment). Your page is mainly generated with 4 elements: header.php, sidebar.php, footer.php and another page to produce the content, but this page is different depending on where you are in the site. If you are on a page, it will be, by default, page.php. If you are reading a post, WordPress will by default use single.php.
To apply all your different templates, just go and open page.php in your theme folder. Save it under another name, like page-template7cols.php. Insert a comment like I just explained above, so this template will show in your admin next time you create a new page. Adapt it the way you want (changing the HTML / PHP and therefore adapting the way the content of the page will be displayed). Do the same for your other 9 templates.
Then, everytime you create a new page, just start by selecting the proper template in your dropdown (see previous screen capture). And whenever you will make a change to page-template7cols.php, for example, the changes will be reflected on all pages for which you have selected this template.
/**
Template Name: Template1
*/
<?php get_header(); ?>
<div class="content-wrap sevencol clearfix">
<div class="row clearfix">
<div class="content">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<?php endwhile; endif; ?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

Need Help for my Custom Page Template

I'm very new to this PHP coding.. actually I'm not a programmer, but I need this help from anyone here...
Anyway, what I need help from you:
I have written a small snippet of Custom Page template, here it is:
------------------------------
<?php
/*
Template Name: MyCustomTemplate
*/
?>
<?php get_header(); ?>
<?php get_footer(); ?>
------------------------------
Now I have installed a wordpress slider plugin "Nivo Slider"..
Now I'm not understanding how do I call this plugin into my custom template...
Iam trying to achive home page with a Slider and some ads in it.. eg: I need my home page like this: www.papayaclothing.com/shop/
So, could anyone please provide me a code to work that?
Please try following code, make sure that slider you are trying to call is published:
<?php
//valid for Nivo Slider version < 1.8
echo do_shortcode('[nivoslider slug="my-slider"]');
?>
Let me know if my answer was helpful.

Wordpress ignoring page template from drop down

I am struggling with something that appears to be easy, page templates. I have read plently posts on this, people seem to forget to put the comment at the top of the page and can't get it to show up in the drop down menu on pages. I can do this, my problem is the next stage.
I have written the most basic template (custom-page.php):
<?php
/*
Template Name: Test template
*/
?>
<?php get_header(); ?>
<h1>Teams!</h1>
<?php get_footer(); ?>
It shows up and I can select it on the new page sidebar. However when I visit that new page it seems to have defaulted the archive page using the content template include.
Thanks in advance.
If you put the following in your footer, you should be able to grok some further information about how your template is being selected (and know exactly what might be happening).
<?php global $template;
echo(basename($template)); ?>
Then look for the template name in your footer. It's possible (like #adomnom said) that you have a slug conflict. There are a handful of other strange scenarios that could be caused by plugins, custom functions, or other factors as well.
By the sounds of things, it could be conflicting with another template.
For example, if your page has the slug 'category' and is set to use the custom template 'custom-template.php', it would conflict with (and be overridden by) category.php, which is the default template for showing posts for a specific category.
I recommend changing the slug to see if that's the problem.

Resources