Download & Extend

Blocks above (before) main Content

Project:Marinelli
Version:6.x-2.96
Component:Code
Category:feature request
Priority:normal
Assigned:mrbrowny
Status:reviewed & tested by the community
Issue tags:add, Marinelli, new, regions

Issue Summary

Hello,

I am new to Drupal and Marinelli theme. I would like to know if it's possible to switch the places of the Blocks and the actual content of the theme in the "main" area (not the sidebars). Basically, what I would like to do is have some blocks with custom content as the first thing the user sees in the main column/area of the Marinelli theme, and then the new stories appearing below these blocks so that the user can scroll down to see more stories or just-posted things.

The goal I am trying to achieve is to have some static content like "about us" or a description of what someone would find on the page to always appear first, and then any new stories will appear further down, if this makes it more clear. I assume the "style.css" must be changed for something like this to work?

Thanks in advance for your help, and thanks to Marinelli team for contributing such a great theme.

-Mike

Comments

#1

Status:active» closed (fixed)

Sorry guys I believe I should tell myself to "RTFM"

LOL.

Thanks anyway for your help.

-Mike

#2

Let everyone know what you found, help out other people who might be looking for the same thing :)

#3

Status:closed (fixed)» postponed (maintainer needs more info)

Hi "mikesfx" and "Winters", i'm looking for exactly the same thing "mikesfx" is asking in the first post. How do i make to display the blocks BEFORE the content and not AFTER? (as is displayed by default)

I really need this info because i need to have the blocks in "content region" to be seen before the content.

Thanks in advance!

Claudio Abraham
(mrbrowny)

#4

Title:Blocks above story content» Blocks above (before) main Content
Version:6.x-1.8» 6.x-2.2
Category:support request» feature request
Assigned to:Anonymous» mrbrowny
Status:postponed (maintainer needs more info)» needs review


*** SOLUTION ***:

Well people, as i'm a little bit hurry, i have made the successfull code to add this feature.

All of this is based in adding new regions to the theme and its variations (Marinelli, Giordani and Gnifetti).

As i have tested, when i added a region before the content itself, i figured out that there were, indeed, three useful regions (locations) to place blocks, so i added the three of them. Anyway if you don't use those regions, the layout won't be affected.

Note that i'm using Giordani subtheme of Marinelli, but it works for all three themes in Marinelli pack.
The only thing you need to see is that in Marinelli, the content section in page.tpl.php is before the left and the right column, and in Giordani, the content is between de columns and in Gnifetti, the content is after the two columns. Just to have no problem while searching the code.


Zero Step - BACKUP UP YOUR FILES BEFORE CHANGES!
------------------------------------------------

That's it, you know, even the more clever programmer forgets this step sometimes.
I have tested the following changes, but sometimes things may not work (perhaps of misunderstanding the tutorial, or other causes)


First Step - Creating the new regions: (theme.info file)
--------------------------------------

Get marinelli/giordani/giordani.info (then do this gnifetti if you want), locate the following line:

base theme = marinelli

Note that in Marinelli (marinelli.info) the line mentioned "base theme = marinelli" will not be there so just insert your code anywhere, or after the "stylesheets[all][] = links.css" line.

And after that line, add the following data:

; Here I'm adding three more regions to add blocks needed to be displayed above (before) the content.
; Note that if you don't define regions, the defaults are used (left, right, content, header, footer),
;    but when new regions are added, default regions must be defined also. If not, default regions won't work.
regions[left] = Left sidebar
regions[right] = Right sidebar
regions[content] = Content
regions[header] = Header
regions[footer] = Footer
regions[top_content_1] = Top Content 1
regions[top_content_2] = Top Content 2
regions[top_content_3] = Top Content 3

And that's the end of first step.

Now we need to place the new regions in the template, to make them be displayed.


Second Step - Placing regions in template: (page.tpl.php file)
------------------------------------------

Get marinelli/giordani/page.tpl.php (then do this in marinelli and gnifetti if you want), and locate the following lines:

<div id="primary" style=<?php print '"width:'.marinelli_width( $left, $right).'px;">' ?>
    <div class="singlepage">

And right after that lines, add the following code:

        <!-- TOP_CONTENT_1: this region will be displayed before the "You are Here" legend in the content column -->
        <?php print $top_content_1 ?>   

Then in the same file locate the following lines:

        <?php print $breadcrumb; ?>
        <?php if ($mission): print '<div id="sitemission"><p>'. $mission .'</p></div>'; endif; ?>

And again right after that lines, add the following code:

       
        <!-- TOP_CONTENT_2: this region will be displayed between "You are Here" and the taxonomy title in the content section -->
        <?php print $top_content_2 ?>

After that, in the same file locate the following lines:

        <?php
       
if ($title):
            if (
$is_front){/* if we are on the front page use <h2> for title */
               
print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h2>';
            }
            else {print
'<h1'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h1>'/* otherwise use <h1> for node title */
           
}
        endif;
?>

And again right after that lines, add the following code:

        <!-- TOP_CONTENT_3: this region will be displayed between the taxonomy title and the list of articles in the content section -->
        <?php print $top_content_3 ?>

That's it, end of changes in the second step.
To be more clear i will show you how the second step was, and how it should be left.

So the original part of the code in Giordani subtheme is:

    <div id="primary" style=<?php print '"width:'.marinelli_width( $left, $right).'px;">' ?>
        <div class="singlepage">

            <?php print $breadcrumb; ?>

            <?php if ($mission): print '<div id="sitemission"><p>'. $mission .'</p></div>'; endif; ?>

            <?php
           
if ($title):

                if (
$is_front){/* if we are on the front page use <h2> for title */

                   
print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h2>';

                }
                else {print
'<h1'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h1>'/* otherwise use <h1> for node title */
               
}

            endif;
?>


            <?php if ($tabs): print '<div class="tabs">'.$tabs.'</div>'; endif; ?>
            <?php if ($help) { ?><div class="help"><?php print $help ?></div><?php } ?>
            <?php if ($messages) { ?><div class="messages"><?php print $messages ?></div><?php } ?>
            <div class="drdot">
                <hr />
            </div>


            <?php print $content ?>
        </div>
    </div>

And the result after adding the lines should be:

    <div id="primary" style=<?php print '"width:'.marinelli_width( $left, $right).'px;">' ?>
        <div class="singlepage">

            <!-- TOP_CONTENT_1: this region will be displayed before the "You are Here" legend in the content column -->
            <?php print $top_content_1 ?>   


            <?php print $breadcrumb; ?>

            <?php if ($mission): print '<div id="sitemission"><p>'. $mission .'</p></div>'; endif; ?>

            <!-- TOP_CONTENT_2: this region will be displayed between "You are Here" and the taxonomy title in the content section -->
            <?php print $top_content_2 ?>   

            <?php
           
if ($title):

                if (
$is_front){/* if we are on the front page use <h2> for title */

                   
print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h2>';

                }
                else {print
'<h1'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h1>'/* otherwise use <h1> for node title */
               
}

            endif;
?>


            <!-- TOP_CONTENT_3: this region will be displayed between the taxonomy title and the list of articles in the content section -->
            <?php print $top_content_3 ?>        


            <?php if ($tabs): print '<div class="tabs">'.$tabs.'</div>'; endif; ?>
            <?php if ($help) { ?><div class="help"><?php print $help ?></div><?php } ?>
            <?php if ($messages) { ?><div class="messages"><?php print $messages ?></div><?php } ?>
            <div class="drdot">
                <hr />
            </div>


            <?php print $content ?>
        </div>
    </div>

Please note that NO ALTERATIONS were made to the original layout or the original values, variables or data. Only were added the regions in the content column.

And that's the end of the second and last step.

Now if you want you should replicate this changes in Marinelli and Gnifetti themes, and also this changes are so clear and simple, that you should apply them to other themes without problem (although i didn't tested them in other themes)


Third Step - Cleaning the cache to see the new added regions:
-------------------------------------------------------------

When you create new theme functions or templates in Drupal 6 you must clear the theme registry. To do this you have to:
- Press the "Clear Cached Data" button located at "Administer -> Site configuration -> Performance"

This works as planned but if you are making lots of changes in the themes, and refreshing continuously and is preety annoying to go to that page and press that button, you may:

- Call the function drupal_rebuild_theme_registry(). Place this at the top of your template.php file while you're developing the site & then remove it from production to prevent huge server load (because it will clear the cache every time the theme is loaded)

You will now have see the three additional available regions on the block configuration page.

And here finishes the third step.

And also this tutorial and feature request, hope you like it and i really hope, the Marinelli team, to add this useful regions (you may change the regions name if you want) to the following release.

See you and tell me if there is any comment.


Claudio Gaston Abraham
(mrbrowny in Drupal.org)
From Argentina
South America

Useful information used make this feature:
http://drupal.org/node/283543
http://drupal.org/node/132442#defining-regions
http://drupal.org/node/171224
http://yubastudios.com/blog/drupal-creating-new-regions
http://drupal.org/node/292028

#5

Awesome!! I was looking exactly this!!! Did you read my mind?! :D

#6

Hahahhaha, i'm glad this solution helped you. Ok if you have any doubt about my solution, just ask me!

See you!

#7

Thanks mrbrowny, that was exactly what also I was missing in this wonderful Marinelli theme! Hopefully the patch will end up to next release. All your guys work very much appreciated!

#8

Will this patch go in?
Thanks a lot for considering this!
Greetings,
Martijn

#9

Version:6.x-2.2» 6.x-2.9

I'm also interested in this patch going in

#10

Great Post but..

I dont want to create regions in my theme because there is a option in my application from which user can change theme so basically there are thousands of themes available , and for this i have to create region in every theme thats why i need a solution for this without creating new regions .........

Any help ?

Thanks

#11

It seems to me you could create a custom node template and embed the block before printing the node content. See this thread for how to embed a block.

http://drupal.org/node/164799

#12

Thanks to mrbrowny, that example worked perfectly. But Now I'm trying to add regions above on another theme (jaded) and it's not built the same. So watch your theme. It may not work.

#13

Version:6.x-2.9» 6.x-2.96
Status:needs review» reviewed & tested by the community

Hi manteiners of Marinelli!

I've seen that many people has tested my solution to add more regions published in #4 ( http://drupal.org/node/292028#comment-1027837 )

Note that a full year has passed from the solution i gave. (published in september 2008 -now we are in sept 2009-)

I'm changing the status to "reviewed & tested by the community".

Would you add it to Marinelli and it's subthemes? It's so important for many of us to have those regions :)

That would be really helpful because everytime i apply your updates of Marinelli theme you publish, i had to manually add this patch of regions.

Note that this doesn't harm the integrity of the theme, because anyone may choose to use or not use those new regions.

Thanks a lot, hoping to see this new regions in Marinelli 6.x-2.97

Claudio Gaston Abraham
(mrbrowny in Drupal.org)
From Argentina

#14

@mrbrowny

Do you know how to create a patch? I recommend doing that.
http://drupal.org/node/323

#15

@mikeytown2

No i don't but now i think i'm gonna learn hahah

Thanks for the link :)

I'll try to make the patch so the manteiners may add this feature to this great theme.

#16

@mrbrowny

I would LOVE you if you made a patch for this issue. What do you think the chances are?

#17

I agree! And thanks for this solution. Brilliant! ;)

#18

I'd like to create a new region below the primary links, but only on the right side of the page above the left and the right sidebars. How do I define the width? It has to be some sort of fixed value. In my case it should be 370 pixels, with region alignment to the right.

#19

All i did was find

<?php
print $breadcrumb;
?>
in page.tpl.php and write
<?php
print $header;
?>
underneath. Is there a reason i shouldn't have done this?

#20

sandwormblues, thanks! it works!

#21

Does the current version 6.x-2.96 dated 8/25/2009 have this feature now? Or do I need to go cutting and pasting all this code into these different places?

#22

We are in 2012, has this been patched through? It will be of great help to all the users like us!

#23

I tried this and did not work for me. Apparently it changed the appearance of my current blocks!

#24

Very helpful! Thanks for taking the time to post this in detail. :-)

nobody click here