Jump to content

Build up website with regions


fabjeck
 Share

Recommended Posts

Hi all, I am new to PW and building up a website for a customer and have some problems with structuring my project:
On my main.php file I have a main-tag where I wan't to echo the region called 'content'. But the problem is that the markup inside this wrapper should be variable.Example: I have a page where all the news previews are outputed  like in a normal news app--> no additional markup is needed. But on "home" I want to have different sections with content -->
 

<section>
    <div class="slider">
        <!--here i want to have some filtered news articles-->
    </div>
</section>

<section>
<div class="news">
        <!--here i want to have some news articles but with another filter-->
    </div>
</section>



How can I realise that? It has to be like that for responsive purposes. 
Is it maybe possible to create and echo regions inside the "parent region"?

Cheers and thank you for your help :)
 

Edited by kongondo
code blocks
Link to comment
Share on other sites

Welcome @fabjeck,

Having different markup for different templates is what the markup regions feature is all about. First, make sure you are up-to-speed with markup regions by reading the related blog posts:

Regarding the #content markup in _main.php and your "normal" template file (let's say it is called "basic-page.php") there are two approaches - either is fine; it's just whatever you find easier to manage. Note that I am only showing a portion of _main.php below - this file needs to include complete HTML page markup: doctype, <head>, <body>, etc.

 

Approach 1: put your normal #content markup in _main.php and leave basic-page.php empty of markup.

_main.php

<div id="content">
    <!-- Your normal markup here -->
    <h1><?= $page->title ?></h1>
    <!-- etc -->
</div>

basic-page.php - no markup

 

Approach 2: put an empty #content region in _main.php and put your normal markup in basic-page.php

_main.php

<div id="content"></div>

basic-page.php

<div id="content">
    <!-- Your normal markup here -->
    <h1><?= $page->title ?></h1>
    <!-- etc -->
</div>

 

And in either approach, your home.php is the same:

<div id="content">
    <!-- Your home markup here -->
    <section>
        <div class="slider">
            <!-- Find and output some news pages using a selector -->
        </div>
    </section>
    
    <section>
        <div class="news">
            <!-- Find and output some news pages using a different selector -->
        </div>
    </section>
</div>

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...