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

[eluser]madrico[/eluser]
how did you handle the if though? i'm using the jquery jeditable plugin and i'm having it post to a method with in my controller. i was hoping that i could easily override the template view of the region that was being affected since the regions are defined and you just want to re-render that region.

please remember this code is still rough and some of it is static because i wanted to get the ajax parts working first before i code a bunch of code and rework to make it work with ajax calls.


Code:
//wrapper ajax call using jeditable - includes all jquery and jquery plugins
$(".ajaxfileupload").editable(baseUrl+"/controller/page/image/", {
        indicator : "<img src='"+baseUrl+"/docroot/images/indicator.gif'>",
        type      : 'ajaxupload',
        submit    : 'Upload',
        cancel    : 'Cancel',
        tooltip   : "Click to upload..."        
    });

//header template
<div id="header">
        <h1>Title</h1>
        <div id="clientLogo">
            <p class="center">
                <img class="logo" src="&lt;?=$image['image_url']?&gt;" /><br />
                &lt;? //if ($acl['edit'] == true) { ?&gt;<span class="ajaxfileupload center">Add/Edit Logo</span>&lt;? //} ?&gt;
            </p>
        </div>
    </div>

/*
* First Rendering of page in my controller
*/
function show($job_id = 0)
    {
        if ($job_id != 0) {
            $job = new Project();
            $jobData['acl'] = $job->getAcl();
            $jobData['project'] = $job->getJob($job_id);
//this will be a image object with image properties to associate in the template, but a test for now
            $jobData['image'] = array("image_url" => base_url().'docroot/images/client-logo.gif');
            if (isset($jobData['project'])) {
                $this->template->write_view('header', 'client/header', $jobData, true);
            } else {
                //redirect
            }
            
            // Render the template
            $this->template->render();
        } else {
            //redirect;
        }
    }
function _setBaseView() {
        // Write to $title
        $this->template->write('title', 'Project | .::Project Name ::.');
        // Write to $header
        $this->template->write_view('header', 'client/header');
        // Write to $titleBar
        $this->template->write_view('titleBar', 'client/titleBar');
        // Write to $content
        $this->template->write_view('content', 'client/content');
        // Write to $rightColumn
        $this->template->write_view('rightColumn', 'client/rightColumn');
        // Write to $rightColumn
        $this->template->write_view('footer', 'client/footer');
    }
    
    function image() {
        $jobData['image'] = array("image_url" => base_url().'docroot/images/client-logo2.gif');
        $this->template->write_view('header', 'client/header', $jobData, true);
        echo $this->template->render('header');
    }

again, this is something i constructed in a day, but i just wanted to make sure that the ajax edit in place wouldn't be an issue with the template refreshes. once i got that working correctly, i was going to put in all the necessary pieces to make this more dynamic.

thanks ahead of time!!
#52

[eluser]M4rc0[/eluser]
Maybe you need something that checks if the request is ajax or not..

MichaelWales did something like this, check it out.

The cool thing about this Template Library is that is very functional and customizable. You won't have trouble at all once you find where the problem is. If it works with load view it will work with write_view, i think Big Grin
#53

[eluser]madrico[/eluser]
hmm, yeah this is weird. i just put in a CI redirect into the image method commenting out the echo statement and just have the method redirect and it doesn't appear to do anything, but i then put in a php redirect using header('location:http://www.google.com') and that threw errors within the header template. it's like it never executed or refreshed.

this is so weird. maybe i should just go back to using the jquery forms plugin.

if anyone has a solution to what's going on, i'm definitely curious.

thanks!!
#54

[eluser]madrico[/eluser]
just wanted to give you an update, i basically replaced all the jeditatable stuff and went back to using the the ajax forms plugin for jquery with some of my own code and it works awesome so far. thanks for your help and i appreciate the forums here.
#55

[eluser]Colin Williams[/eluser]
I still don't have a fully comprehensive understanding of what's happening, but I'm glad things are working out for you.
#56

[eluser]opel[/eluser]
I have downloaded and followed the installation instructions but I cannot get Template to work with the Matchbox Module Library.

I have put my master layout in modules/front/view/layout.php and tried to change the paths from the template library from

"views/"

to

"modules/front/view/"

IS there anything I have missed or will template not work with modules/matchbox ? I am slowly finding that most libraries don't like module structure
#57

[eluser]Colin Williams[/eluser]
Template will look in the application/views/ folder. You can hack the lib to follow Matchbox's loading cascade. You could optionally do a symlink from app/views/ to modules/whatever/view

Quote:I am slowly finding that most libraries don’t like module structure

That's what happens when you break conventions.
#58

[eluser]opel[/eluser]
I am new to CI coming from using ZF, which takes ages to get something up and running, and I thought the cconventions of CI would be to use modules.

I have went back and started my app again without using modules as I see most libraries don't use them.
#59

[eluser]madrico[/eluser]
hello,
first let me say again that these forums rock!! you've might have gone over this previously, but i wanted to ask again how do i override a defined template so that it renders that template as opposed to the defined default template in the config?

i thought it was
Code:
$this->template->config['default']['template'] = 'new_wrapper';
or
Code:
$this->template->config['template'] = 'new_wrapper';

something along those lines. i do a print_r on the template object and i can see it being somewhat overridden, but the view is still rendering the default template for this one method in my controller.

in the mean time, i'm using the
Code:
$this->load->view('new_wrapper')
, but i want to keep it consistent.

thanks again!!
#60

[eluser]Colin Williams[/eluser]
You will call the set_master_template() method from your controller (or library, or hook, wherever it makes sense). [url="http://williamsconcepts.com/ci/codeigniter/libraries/template/reference.html#manipulation"]Refer here for documentation and examples of this particular functionality[/url]




Theme © iAndrew 2016 - Forum software by © MyBB