ansonphong / postworld

Wordpress Theme Development Framework
GNU General Public License v2.0
7 stars 0 forks source link

pw_get_templates() - Path Options #49

Closed ansonphong closed 10 years ago

ansonphong commented 10 years ago

Hi Haidy, I was just working with pw_get_templates(), and it doesn't seem to be scanning the over-ride paths for files, always returning only what is in the plugins path.

I had success by changing the paths in postworld_options.php from double backslash to forward slash and that made it work.

OLD

'default_posts_template_abs_path' => ABSPATH . "wp-content/plugins/postworld/templates/posts/" ,
        'override_posts_template_abs_path' => get_template_directory()."\\postworld\\templates\\posts\\",
        'default_panel_template_abs_path' => ABSPATH . "wp-content/plugins/postworld/templates/panels/" ,
        'override_panel_template_abs_path' => get_template_directory()."\\postworld\\templates\\panels\\",

NEW


'default_posts_template_abs_path' => ABSPATH . "wp-content/plugins/postworld/templates/posts/" ,
        'override_posts_template_abs_path' => get_template_directory()."/postworld/templates/posts/",
        'default_panel_template_abs_path' => ABSPATH . "wp-content/plugins/postworld/templates/panels/" ,
        'override_panel_template_abs_path' => get_template_directory()."/postworld/templates/panels/",

Are there any foreseeable issues that may be caused by this change?

hmikhail commented 10 years ago

No, this will work fine.

ansonphong commented 10 years ago

Hi Haidy, I have re-opened this Issue in order to make an addition to the function.

I have added to the documentation a "Comments Template Object"

It's a clone of the panels template object, though is called comments and scans the /postworld/templates/comments plugin theme folder for over-rides, and returns it in the pw_get_templates() function.

This will allow us to theme the comments templates.

ansonphong commented 10 years ago

The documentation is in here:

pw_get_templates ( $templates_object ) ›› Process

hmikhail commented 10 years ago

Phong, this addition is done but please note that now retrieving comment template is hard coded. Let us know if you want to change it.

ansonphong commented 10 years ago

Hi Michel, Haidy pointed out the comments template is hard-coded, and how we have a function to get an over-ride from the postworld/templates/comments directory, so we can implement that now using the URL from the action pw_get_templates.

michelhabib commented 10 years ago

Yes, can you please look at the templates/directives/loadComments.html current template, and confirm that this is how a comment template would look like? i find it to have much of the ui for the whole tree, not for a single comment, it is kind of hard to decouple them, given the complexity of the component. any ideas are welcome, you may for instance indicate pieces of that template that can be separated.

Adding the template dynamically is very simple, i will work on that, it's just the idea of having any user edit that is a bit scarry, unless it is someone who is a developer like yourself.

ansonphong commented 10 years ago

Hi Michel, Sure I understand the complexity issue of breaking the comments apart from the main template. At this point it would go beyond scope/budget to break it apart.

I'm fine to edit it like that for the meantime : we can just move it into /templates/comments/loadComments.html, so we can create an over-ride file.

michelhabib commented 10 years ago

This is now updated in the latest commit.

Thanks for understanding, i moved the comments template to /templates/comments/comment-default.html I also added a view parameter to the array, it looks and works like this now:-

var load_comments = [];
load_comments['post_single'] = {
    query : {
        post_id : 133925, // 21853, // 133925, // 166220, // 21853, // 166220,
        status: 'approve',
        orderby : 'comment_date',
        },
    fields : 'all',
    tree : true,
    order_options : {
        'comment_points' : 'Points',
        'comment_date' : 'Date'
        },
    min_points : 50,
    view: 'default', // Optional, default value is default
};

this will give you the flexibility to play with the template while having a default one that you can always go back to.

michelhabib commented 10 years ago

i wanted to note something here as well. Just to make this as optimized as possible, i am calling pw_get_templates only once and return everything and keep the template mapping in pwData. Then whenever any function is requesting a specific template, i get it from the cached template in pwData. you would still be using pw_get_template, but it is internally getting the info from the cached value, not from the server, this way it saves many unnecessary trips to the server. This cache will be refreshed every time you refresh the browser, so it is still gonna be a fresh cash every time you open the website.

ansonphong commented 10 years ago

So is it downloading all the templates at once? Or just keeping the template URLs in a cache for when it needs them?

Phong

On Wednesday, October 30, 2013, michelhabib wrote:

i wanted to note something here as well. Just to make this as optimized as possible, i am calling pw_get_templates only once and return everything and keep the template mapping in pwData. Then whenever any function is requesting a specific template, i get it from the cached template in pwData. you would still be using pw_get_template, but it is internally getting the info from the cached value, not from the server, this way it saves many unnecessary trips to the server. This cache will be refreshed every time you refresh the browser, so it is still gonna be a fresh cash every time you open the website.

— Reply to this email directly or view it on GitHubhttps://github.com/phongmedia/postworld/issues/49#issuecomment-27417046 .

michelhabib commented 10 years ago

Exactly, Just keeping the template URLs cached. this is what you receive from pw_get_tempaltes, just the urls. The actual Templates are only retrieved when they are associated with a directive.

ansonphong commented 10 years ago

this is a good method. I had thought down the road to have a PHP caching mechanism to cache the templates object. the cache can be enabled when development is not taking place, which would prevent a lot of checking the file index every time a page loads in high traffic conditions, though this can happen later.

phong

On Wed, Oct 30, 2013 at 11:03 AM, michelhabib notifications@github.comwrote:

Exactly, Just keeping the template URLs cached. this is what you receive from pw_get_tempaltes, just the urls. The actual Templates are only retrieved when they are associated with a directive.

— Reply to this email directly or view it on GitHubhttps://github.com/phongmedia/postworld/issues/49#issuecomment-27420037 .