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

[eluser]steelaz[/eluser]
Works very well for me (tested in all major browsers). From your example it looks like you forgot to close it. Basically when you have
Code:
<base href="http://127.0.0.1/dev/project/" />
you browser will look for http://127.0.0.1/dev/project/assets/css/main.css . Also check if you have forward slash at the end of your url in config file.
#42

[eluser]newsun[/eluser]
http://www.w3schools.com/TAGS/tag_base.asp is a good reference for the html base tag.

[quote author="M4rc0" date="1221318608"]Thanks for the _remap() tip.
So if i put template_render there, can i remove the template_render method from all functions within a controller?
Looks a lot better to me.

And yes, it was the absolute path problem Tongue
Funny i was typing and got the idea. I don't like absolute paths, when i change host i will have to change there again.
What's the correct way to concatenate with base_url() ? I couldn't do it.

Thanks Colin Smile[/quote]

I usually create a method for displaying data with the template calls all grouped and then I just pass my data and content in. Something like this:

Code:
function _display_page ($title, $page_name)
    {
        $this->template->write('title',$title); #append data to title
        $view = $this->Views->retrieve_template($page_name); #retrieve the content from db
        $view = $this->template->parse_string($view, $this->config_data); #parse content for config vars, added this method to the Template class
        $this->template->write('content', $view); #write content region
        $this->template->render(); #render(output to screen) the template
    }

Then I might call this by

Code:
$this->_display_page('Home Page', 'home');

Then it would do all those things and I typically do all of these each time I display a page for different methods in my controller so each will call this. I have a bit of custom stuff here for pulling data out of a db instead of a file then parsing it for vars as a standard view file would. parse_string is something I extended the template library with. Just giving you an example of how you can make the framework into the structure you need it.
#43

[eluser]M4rc0[/eluser]
Thanks for the base tip guys.
That helped a lot!

I didn't know xhtml had such thing.

I will consider your template methods in the future, for now i'll stick with template->render() even if it's repetitive, but very understandable.

Thanks again!
#44

[eluser]newsun[/eluser]
Totally make it clear to read...I just was replacing 5 methods/function used in multiple controllers and this is why I moved them into an internal method.
#45

[eluser]Colin Williams[/eluser]
That is a good method, newsun, especially in that context.
#46

[eluser]madrico[/eluser]
hello,
let me just say i really like codeigniter and this template library. it makes creating a wrapper template very easy, but i'm running into issues with using ajax, and in particular the jeditable jquery plugin. basically, there is a show method that handles the first rendering of the wrapper view with it's defined regions. within this header region i have a file upload to change the logo of the header and that calls the image method within the same controller class. i handle the image and then i use the:

Code:
$this->template->write_view('header', 'logo/header', $data, true);
$this->template->render('header');

to rerender the header region, but what ends up happening is that it duplicates the header within the header instead of overriding it or replacing it; am i doing something incorrectly?

please help?!?!?
#47

[eluser]Colin Williams[/eluser]
It sounds, madrico, like the problem lies in the JavaScript and what you are replacing. When your Ajax call returns only the header HTML, are you replacing all the header code, or simply embedding it in the current header? That would make sense that the header gets embedded in the header if your JS is replacing the wrong DOM elements.

Also remember that the Ajax call is a new request, so the Template library would have no reference to the HTML currently being viewed.
#48

[eluser]madrico[/eluser]
hello colin,
thanks for replying so quickly! actually, the jquery plugin isn't even posting as a ajax call. i think it's treating it as a form post to that method; i could be mistaken though. i tried that ajax code snippet you posted and it didn't do anything. i was combing through some previous posts, but should i try emptying the region and then reload it through the render echo statement because it is embedding the header in the header.

any thoughts?
#49

[eluser]newsun[/eluser]
Maybe show some code in how you are doing things. From your initial description I thought similar to Colin with it being a duplicated header from an AJAX call.
#50

[eluser]M4rc0[/eluser]
I was having duplicate calls here as well.

But i fixed by cleaning my code a bit and making one unique IF with the render write_view & inside.
You should try to see if you can do the same.

I'd like to see your code as well, i'm thinknig about adding some jquery stuff on my template, but only after everything is working well Big Grin




Theme © iAndrew 2016 - Forum software by © MyBB