Code Monkey home page Code Monkey logo

ocular-template-library's People

Contributors

lonnieezell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ocular-template-library's Issues

render helper

if ( ! defined('BASEPATH')) exit('No direct script access allowed');

if ( ! function_exists('render'))
{
function render($data = array())
{
$CI =& get_instance();

    $CI->template->set($data);
    $CI->template->render();
}

}

// ------------------------------------------------------------------------

I found this useful and created for myself.
hope you like this idea.
it makes controller cleaner

Pass array directly to template->set

I've modified Template.php to check if the $var_name is an array, and if so, walk it to set the key/vals on this->data.

This makes it easier to migrate an existing site that is using CI's standard $data way to Ocular.

Would be nice to have this implemented so future versions don't need to be patched.

Return layout/view as string rather than render to screen

Apologies if I'm missing something really simple here, but I need this functionality and I can't see how it is achieved.

This would be the equivalent of the standard CI $string = $this->load->view('myfile', '', true);

Can somebody point me in the right direction?

Thanks

Controllers in sub-folders

When controllers are organized into sub-folders, the Template->render function should look in sub-folders for views too (mentioned as a future to-do on the old website).

I think it's as simple as adding the router->directory to line 236, like so:

$this->current_view = $this->ci->router->directory . $this->ci->router->class . '/' . $this->ci->router->method;

active_theme

public function theme()
{
return $this->active_theme();
}

active_theme() is not a function, it is a variable

Not reverting view loads to default theme.

I'm working on troubleshooting this one, but wanted to log it.

Seems like if I have a theme set (this->active_theme) and it's missing a view file, it will never get to loading the missing file from the this->default_theme folder.

Upon cursory review, it seems the Template.php library is relying on $content being populated from CI->load->view to determine how to proceed. This is a catch-22 in that if CI-load->view can not find the passed view name (because say we want to revert to default), CI will throw a 404, never allowing Ocular to revert to this->default_theme's view.

I'm testing this in 2.0, FWIW.

$bypass always set to FALSE ?

The $bypass always set to FALSE, the effect is the view rendered first before the layout (the yield method $this->template->yield not running)
then i hardcoded the function (yield) i set the $bypass to TRUE, then is running.

public function yield($bypass=FALSE) {
$this->_mark('Template_Yield_start');
// If we've cached the layout, we don't return anything except the
// yield function itself.
if ($bypass === TRUE) { // I CHANGED TO TRUE
return '{yield}';
} else {
$this->_render_view($this->current_view, $this->cache_view);
}
$this->_mark('Template_Yield_end');
}

view content echoed before layout content

I installed the latest version and did a very basic test. I found that when I viewed the source code, the view content was showing up above the layout content. I looked through the code and here's what I found:

In the Welcome controller index method, I call the template render method:

$this->template->render();

In theTemplate libraray render() method, {yield} string is replaced with the return value of the yield function (with bypass set to true):

$output = str_replace('{yield}', $this->yield(true), $output);

However, the yield function doesn't seem to return a value when bypass is set to true (line 321):

$this->_render_view($this->current_view, $this->cache_view);

... and the called _render_view() method doesn't return view content either, but instead echos the content directly (line 727):

echo $content;
return true;

The end result of this seems to be that calling $this->template->render() in my controller echoes the view content, then the layout content. Am I missing something, or is this a bug?

HMVC

Would you mind providing some info to make Ocular work with HMVC plz?

Block's Don't Accept Data from the View

Hopefully the title here isn't too confusing, and this is more a request than an issue.

Right now, Block's can be rendered using data provided by the Controller, but not by the parent View. For instance, I have the following:

<ol>
<?php foreach ($entries as $entry) { ?>
    <li>
        <h3>$<?= $entry->amount; ?></h3>
        <h2><?= $entry->description; ?></h2>
        <p><?= $entry->budget; ?></p>
    </li>
<?php }; ?>
</ol>

I was hoping to be able to extract the HTML for a single entry, and use it as a Block. I was hoping that I could updated my View to be:

<ol>
<?php foreach ($entries as $entry) { ?>
    <?= $this->template->block('single_entry', 'entry/single'); ?>
<?php }; ?>
</ol>

With my single.php view (partial?) containing:

 <li>
    <h3>$<?= $entry->amount; ?></h3>
    <h2><?= $entry->description; ?></h2>
    <p><?= $entry->budget; ?></p>
</li>

However, it appears that the $entry variable isn't passed to the block. Not sure if I'm missing something.

It would be really great to have support for something similar to rails collections, using the format:

<ol>
<?= $this->template->block('single_entry', 'entry/single', $entries as $entry); ?>
</ol>

Anyways. Great work! I'm loving Ocular!

themed_view()

Hello,

I'm trying to put in my aplication.php file to load a menu.php file. but the browser stop in that place.

i don't find any documentation about the function in the wiki.

i was seeing the function and the code and i think the error is in $ci->template->render_view($view);

Tanks,
Domingos

Current View Name Always Displayed

I may be missing a config, but the Current View is always displayed at the top of the page:

Lines 233 through 239 of application/libraries/Template.php:
// Grab our current view name, based on controller/method
// which routes to views/controller/method.
if (empty($this->current_view))
{
$this->current_view = $this->ci->router->directory . $this->ci->router->class . '/' . $this->ci->router->method;
echo 'Current View = '. $this->current_view;
}

I couldn't find any way to turn this off, other than commenting out the echo statement.

Session load to use message()

Because it uses session library from CI Core, I had to follow two steps to get messages working correctly:

  1. Assign an encryption key in config/config.php;
  2. Autoload the session library in config/autoload.php:
    $autoload['libraries'] = array(..., 'session');

Is there a way not to use sessions? I didn't figure out why.

Thanks for the best CI template library!

set_message() not clearing

Just as the title suggests, when using the set_message method to set flashdata, the message displayed once on the resulting render and again on the subsequent page load. I looked at the method in the template library to find a typo that fixed the problem once corrected. Here is the typo:

In the template library, at the end of the message method, find

$this->ci->session->flashdata('message', '');

and replace it with

$this->ci->session->set_flashdata('message', '');

AJAX layouts not correct in repo

The following changes need to be made:

in views/layout/ajax.php:

ocular->yield(); ?>

to

template->yield(); ?>

and in Template.php, line 234:
$layout = $this->ci->config->item('OCU_layout_folder') . $this->ci->config->item('OCU_ajax_layout');

viewing not in the right way...

i have this this action in Welcome controller:
function index() {
$this->template->render();
}
i create 1 view ('view/welcome/index.php') and the content is

Test


when i run the web, the index view not render in template->yield(); ?> block.

i got this:

Test

<title></title>

Page rendered in {elapsed_time} seconds using {memory_usage}.

yield() method conflicts with PHP 5.5+ "yield" keyword

Getting "Parse error: syntax error, unexpected 'yield' (T_YIELD), expecting identifier (T_STRING) in .../application/libraries/Template.php on line 314", when using PHP 5.5+, where there is a new keyword "yield", which conflicts with the method name used in the library.

echoing Current View

On line 238 of the library file, is that an oops? I'm new with Codeigniter, took a bit to figure that out, it displayed at the top of every page

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.