Welcome Guest, Not a member yet? Register   Sign In
Template Library Version 1.4
#71

[eluser]M4rc0[/eluser]
calligrim, I believe so! but let someone else here confirm. I think everytime you want it to load you declare it or else $footer and $header will be blank. Again, let someone else here confirm Tongue

But Do you have data to display on header and footer that is generated dynamically?

I have a header and footer on my template too but since I'm not displaying $data there no need to declare them like you are doing, if that is the case. Because i see you are not passing $data to them as well.
----

Now i have a problem as well, I am not sure if this is a template library related, if not I'll created a new topic for this. I have a test server here (apache) on my computer and it's conected to a network through a router. If i access on another computer http://IP/projectname i can see the page, but the problem is when i try that with my CI it's showing the page without CSS! Like all blank and blue links, big black headers and etc.

When i click to view source it's there, the base url tag and the stylesheets, and here on my computer when i try http://localhost/project it shows correctly. But not on other computers.

Is this a template problem?
#72

[eluser]Colin Williams[/eluser]
calingrim, it is better to just have header and footer in the main template file, especially if they don't rely on $data being passed to them. Even if they do require data, you can still keep them in the master template, you'll just need to write to those regions in each controller's constructor, or $this->load->vars() works too.

M4rc0, the likely problem is that you have relative paths to your css files. You should have absolute paths to these files to make sure they always resolve. Also, you can prepend a call to base_url() to retrieve the site root.
#73

[eluser]M4rc0[/eluser]
But I'm using the base url tag mentioned in this topic:

Code:
<base href="http://localhost/videoteks/" />
<link rel="stylesheet" type="text/css" href="public/stylesheets/custom.css" />
<link rel="stylesheet" type="text/css" href="public/stylesheets/screen.css" />

It's working perfectly. And it's semantic, all I'll have to change in the future is the base href tag, and right now i have so many links that changing one by one with absolute path seems troublesome (and re-changing later if I change server?).

You think <base href> wouldn't work in a network or something?

I'm confused why it wouldn't work. Any ideas?
#74

[eluser]Colin Williams[/eluser]
Quote:and re-changing later if I change server?

No, this is why you use the base_url() and site_url() functions. When you always use those, all you need to change is 'base_url' in app/config/config.php

The other option is to use domain-independent paths, which start with a forward-slash, like /public/stylesheets/custom.css
#75

[eluser]M4rc0[/eluser]
domain-independent path doesn't work for me, I don't know why.
I just did like you mentioned /public/stylesheets/custom.css and everything is blank.

So I'm gonna try the base_url() function.

If it loads correctly on a different computer, then base url was the problem.

EDIT: Could you help me here? This is not working:
Code:
<link rel="stylesheet" type="text/css" href="<?=base_url();?>/public/stylesheets/custom.css" />
Any syntax error?

EDIT2: Nevermind the base_url, the <base> html tag have to work. I checked the code from another computer and the link is there, correctly, just like as i view from localhost. This is not template related.

EDIT3: Found the problem! The computers can't find "localhost", it has to be the ip. So i've changed the base href to the ip instead of "localhost".

Thanks anyway!
#76

[eluser]AgentPhoenix[/eluser]
Colin, I hope you don't mind, but I added to your library for my project. I was having a helluva time doing time refreshes. I tried use the CI redirect helper, but since it's done with a header, it wasn't working properly. I added a method to the Template library called add_redirect which works just like the JS and CSS methods. Below is the code I added.

First, I started by adding a redirect region to the constructor and the write method.
Code:
var $regions = array(
    '_scripts' => array(),
    '_styles' => array(),
    '_redirect' => array(),
);

After that, I just copied the add_css method and changed it around:
Code:
function add_redirect($location = '', $time = 5)
{
    $success = TRUE;
    $redirect = NULL;

    $this->CI->load->helper('url');
        
    $url = site_url($location);
        
    $redirect = '<meta http-equiv="refresh" content="'. $time .';url='. $url .'" />';

    // Add to redirect array if it doesn't already exist
    if ($redirect != NULL && !in_array($redirect, $this->redirect))
    {
        $this->redirect[] = $redirect;
        $this->write('_redirect', $redirect);
    }

    return $success;
}

This could be probably be added to further by setting up whether it's an internal redirect or to an external site, but for my project, external redirects aren't really going to be used. I'm not sure if this is something you'd be interested in using, but if it is, feel free to use what I wrote or even improve on it. Thanks for the awesome library!
#77

[eluser]Colin Williams[/eluser]
Quote:I tried use the CI redirect helper, but since it’s done with a header, it wasn’t working properly.

Right, it is done with an HTTP header, not an HTTP-Equiv meta tag. Template does not interfere with HTTP headers in any way (all it does is load views). You are likely having a different issue with the redirect() function that is not at all related to Template.

And besides, doing this with Template is a perversion of its role. Template is intended to manage where content ends up, not to dish out new HTTP requests.
#78

[eluser]AgentPhoenix[/eluser]
No, I realize that the redirect stuff not working doesn't have anything to do with Template, but this was really the only way around it.

For instance, I wanted a page that displayed "You have been logged in. Redirecting in 5 seconds" when someone logs in. Using redirect, I went directly to that page, then tried to do a new redirect that waited 5 seconds, except that it would delaying going to the message page for 5 seconds then go straight to the admin control panel. Changing Template to do this is the only way I could get around the problem.
#79

[eluser]Colin Williams[/eluser]
Ah... that makes sense, AgentPhoenix.
#80

[eluser]Tony Nash[/eluser]
@Colin Cool…..Great stuff!

Q) With this lib, is it possible to call controllers from view? ex; If I want to call list_latest_post() on side bar of my template for every page?

Also, it would be grate if you could compile documentations into a download package.




Theme © iAndrew 2016 - Forum software by © MyBB