Welcome Guest, Not a member yet? Register   Sign In
How to load a view like theme_view('metadata')
#1

[eluser]Massimiliano Marini[/eluser]
Hi all,

In my theme I want to load the metadata.php file directly in default.php file, like theme_view('metadata').

My complete folder structure is this:
Code:
application/themes/my_theme/views/layouts/default.php

and the metadata.php is here:
Code:
application/themes/my_theme/views/metadata.php

Into default .php between
Code:
<head></head>
tags I want to put something like this
Code:
theme_view('metadata')

I think it must be something like a theme_helper.php, Phil Sturgeon do this in PyroCMS, I've tried to reproduce it but without success.

Any idea or help?
#2

[eluser]Massimiliano Marini[/eluser]
I try to give more information with my code:

Code:
application/themes/my_theme/views/layouts/default.php

The content of default.php is:
Code:
<!DOCTYPE HTML>
&lt;html&gt;
&lt;head&gt;
  &lt;?php echo theme_view('metadata'); ?&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;?php echo $template['body']; ?&gt;
&lt;/body&gt;
&lt;/html&gt;

Code:
application/themes/my_theme/views/metadata.php

The content of metadata.php is:
Code:
&lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;&lt;?php echo $template['title']; ?&gt;&lt;/title&gt;

&lt;?php echo css('style.css'); ?&gt;
&lt;?php echo js('http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js'); ?&gt;

&lt;?php echo $template['metadata']; ?&gt;

In default.php file I want to write only theme_view('metadata') and not $template['partials']['metadata'] because I do not want to write in every controller: $this->template->set_partial('metadata', 'metadata'), I do not like this.

How do you do this?




Theme © iAndrew 2016 - Forum software by © MyBB