#1 2014-06-09 19:01:45

levbao
Member
Registered: 2014-03-12
Posts: 19

How to include Theme's header/footer from module's view

Hi,

From my module's view, I need to include the Theme's header.  I've tried this:

<ion:partial path="/themes/foundation5/views/interior-head" parse="no" />

but it returns empty.

How do I include Theme's header/footer from module's view?

Thank you very much.

Last edited by levbao (2014-07-14 19:16:29)

Offline

#2 2014-06-10 12:33:49

otemu
Member
Registered: 2014-03-07
Posts: 183

Re: How to include Theme's header/footer from module's view

Hi,

Sadly ion partial will not work

Build a module
But...
We do not have the website's design, and of course the navigation menu isn't displayed !
This job is done by the Tag Manager of ionize and no easy lib gives today access to the same functionalities (this will certainly be developed in the future).

Offline

#3 2014-06-21 02:26:13

levbao
Member
Registered: 2014-03-12
Posts: 19

Re: How to include Theme's header/footer from module's view

Hi Otemu,

Please advise how to include header/footer in module's view or controller.

Thank you very much.

Offline

#4 2014-06-23 13:59:19

otemu
Member
Registered: 2014-03-07
Posts: 183

Re: How to include Theme's header/footer from module's view

Hi,

This is something I haven't got round to trying, however two things come to mind

method 1 - quickest method but not so efficient:

Create a view for footer, add some code

here is my footer

Add this to your theme as a page within ionize cms, give the logical name as footer
create a page in ionize cms as footer, link this page to your footer view
make sure you can see the view by going to the url yoursite.com/footer

now in your module view to include the footer you can make an ajax request

<!-- load jquery -->
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js" >
</script>
<!-- here you can load the header -->
<div id="header"></div>
Your module content here
<!-- now load the footer here -->
<div id="footer"></div>
<script>
//ajax request to get the footer
$.get( "footer", function( data ) {
	$( "#footer" ).html( data );
});
</script>

Apply the same technique for your header.
You could use pure javascript to make the ajax request instead of having to load jquery in your module and could put static common content in separate views for you module to load.

Method 2 - more efficient but longer:

Your need to handle tags within your module, look out how tags are handled currently within ionize to get an idea
application\core\MY_Controller.php - check out class Base_Controller
application\libraries\Tagmanager.php
application\controllers\page.php - check out function index()

Then your need to implement a similar method within your modules, sadly I haven't got full example of that as it not something I can do in a few minutes.

Hope that helps

Offline

#5 2014-06-23 18:57:02

levbao
Member
Registered: 2014-03-12
Posts: 19

Re: How to include Theme's header/footer from module's view

Hi Otemu,

Thank you very much for shedding light on this.  It really helps.

Best Regards,
Bao

Offline

#6 2014-06-24 09:13:14

damascus
Member
From: Brisbane, Australia
Registered: 2013-04-08
Posts: 270
Website

Re: How to include Theme's header/footer from module's view

@levbao

If this solution works, please update the topics title to include [solved] so others can see this

Thanks


Webmaster | OneCNC Australia

Offline

#7 2014-07-14 19:16:02

levbao
Member
Registered: 2014-03-12
Posts: 19

Re: How to include Theme's header/footer from module's view

Hi Otemu,

I thought I was close but not sure if I am doing it right.

This is my ThemeTemplate_Tags class in /application/libraries/Tagmanager

class ThemeTemplate_Tags extends TagManager {
    public static function tag_header() {       
        return self::render("header", true);
    }
   
    public static function tag_footer() {
       return self::render("footer", true);
    }
}

From module controller

$this->template['themeHeader'] = ThemeTemplate_Tags::tag_header();

It does render the theme view header.php with basic ion tags like <ion:current_lang />,<ion:theme_url/>.

However the page, languages, navigation tags not rendered

<ion:page id="62">
        <ion:articles limit="1">
            <ion:article:content />
        </ion:articles>
</ion:page>

<ion:languages tag="ul" class="language-list">
        <li <ion:language:is_active> class="active"</ion:language:is_active>>
            <a href="<ion:language:url />"><ion:language:name /></a>
        </li>
</ion:languages>

<ion:navigation tag="ul" class="nav" menu="myMenu" level=2>
         <li<ion:is_active> class="active"</ion:is_active>>
            <a href="<ion:url />"><ion:title /></a>
         </li>
</ion:navigation>

Got error for the page tag

Message: Invalid argument supplied for foreach()
Filename: Tagmanager/Page.php
Line Number: 372
public static function get_page_by_id($id_page){
        foreach(self::registry('pages') as $p){
            if ($p['id_page'] == $id_page)
                return $p;
        }

        return array();
}

self::registry('pages') is empty

Please help.

Thank you very much.

Last edited by levbao (2014-07-14 19:33:05)

Offline

#8 2014-07-20 00:29:58

Michel-Ange
Ionize Core Team
From: Paris, France
Registered: 2010-03-22
Posts: 927
Website

Re: How to include Theme's header/footer from module's view

@levbao : please use the "code" bbcode to make your code readable.

From 1.0.6 :

In your module controller (here the "Demo" module) :

/modules/Demo/controllers/demo.php :

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Demo extends My_Module
{
	public function __construct()
	{
		parent::__construct();
	}

	function index()
	{
		$this->render('my_view');
	}
}

/modules/Demo/views/demo.php :

<ion:demo >
	<ion:partial view="my_partial" />
</ion:demo >

/modules/Demo/views/my_partial.php :

<h2>Ho Ho the partial !</h2>

Inspiration & Innovation : Websites by Partikule, Agence Web Paris

Offline

#9 2014-10-15 06:54:36

swinbox
Member
Registered: 2014-10-15
Posts: 4

Re: How to include Theme's header/footer from module's view

i also want to know how to load theme in module's view, seem like no one know it...

Offline

What's Ionize ?

Ionize is an Open Source Content Management System created by webdesigners for webdesigners.

Created and maintained by Partikule and Toopixel, Ionize wants to be the easiest and most powerful CMS.

Can I help ?

Because talent is nothing without involvement, we are looking for motivated coders and webdesigners to join the project team.

Resources

Website : ionizecms.com
Documentation : doc.ionizecms.com

Development : Ionize on GitHub
Translations : Ionize Translations