Welcome Guest, Not a member yet? Register   Sign In
How is good way to use hooks
#1

[eluser]WebMada[/eluser]
Hi!

General pattern of today's webpages are header-main content-footer, header & footer are often static
I see when searching that we often use hooks when creating $GLOBALS variables to use in header and footer
Is is the best way?
#2

[eluser]Unknown[/eluser]
I tend to just have my header and footer in two separate views, passing variables to them for meta data, title, css files etc.

An example could be:

$data = array(
'title' => 'Title',
'meta_keywords' => 'Keywords, go, here',
'meta_desc' => 'Description is here',
'css' => 'css.css',
'js' => 'js.js'
);

$this->load->view('page_head', $data);
$this->load->view('index');
$this->load->view('page_foot');
#3

[eluser]WebMada[/eluser]
I admit that this is another way but it's too heavy: always calling header and footer in each call of a page
Generally, don't we use:
<?php
$this->load->view("vwHeader");
?>
..........
<?php
$this->load->view("vwFooter");
?>
#4

[eluser]Zeeshan Rasool[/eluser]
[quote author="WebMada" date="1272309209"]I admit that this is another way but it's too heavy: always calling header and footer in each call of a page
Generally, don't we use:
<?php
$this->load->view("vwHeader");
?>
..........
<?php
$this->load->view("vwFooter");
?>[/quote]
Agreed ! actually its simple way to do that. If the header and footer are not static and vary from page to page then we can call them in controller as partial or using parser.
#5

[eluser]WebMada[/eluser]
Let's go to my first question, what about hooks? When to use it
#6

[eluser]paulc010[/eluser]
Hooks aren't that useful for this I don't think. Maybe for post-processing, but not much else really. Have you looked at any of the template libraries, combined with some form of "Modules"?

Paul
#7

[eluser]WebMada[/eluser]
I thought that we use hooks when header & footer contains datas like dynamic menus, etc.
#8

[eluser]mddd[/eluser]
Hooks are for doing things before or after the regular processing of CI.
Maybe your php server needs some special settings. Or you want to load a database in a special way. That kind of things.
Loading data, outputting views etc. should be done in the normal way - through your conroller, models and views.




Theme © iAndrew 2016 - Forum software by © MyBB