Plugin Directory

Changeset 861174


Ignore:
Timestamp:
02/19/2014 09:23:07 PM (12 years ago)
Author:
orillacart
Message:

Add ability for overriding the shop templates more easily.

Location:
orillacart/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • orillacart/trunk/com_shop/front/views/product/view.html.php

    r802008 r861174  
    2222
    2323
    24         add_filter('override_shop', array($this, 'override_templates'), 1, 9);
     24        add_filter('edit_template_paths_shop', array($this, 'override_templates'), 1, 9);
    2525
    2626        if (has_post_thumbnail()) {
     
    210210
    211211    public function override_templates(array $paths) {
    212         $paths[] = dirname(__FILE__) . "/templates/" . $this->row->product->tpl;
     212
     213        foreach ($paths as $k => $v) {
     214            $paths[$k] = trailingslashit($v) . $this->row->product->tpl;
     215        }
    213216        return $paths;
    214217    }
  • orillacart/trunk/com_shop/front/views/product_list/view.html.php

    r852296 r861174  
    1717        ));
    1818        $this->assign('pagination', $pagination);
    19         add_filter('override_shop', array($this, 'override_templates'), 1, 9);
     19        add_filter('edit_template_paths_shop', array($this, 'override_templates'), 1, 9);
    2020
    2121        Factory::getMainframe()->addscript('jquery');
     
    7777    }
    7878
    79     public function override_templates($paths) {
    80         $paths[] = dirname(__FILE__) . "/templates/" . empty($this->category->list_template) ? 'list.tpl.php': $this->category->list_template;
    81    
    82         return $paths;
     79    public function override_templates(array $paths) {
     80
     81        foreach ($paths as $k => $v) {
     82            $paths[$k] = trailingslashit($v) . $this->row->product->tpl;
     83        }
     84        return $paths;
    8385    }
    8486
  • orillacart/trunk/com_shop/helpers/fields.php

    r802008 r861174  
    8989
    9090        public function remove_field($name) {
    91             if (array_key_exists($name, $this->_fields)) {
     91           
     92            if (array_key_exists($name, $this->_fields)) {
    9293                unset($this->_fields[$name]);
    9394                return true;
     
    127128        protected $_error_msg = '';
    128129        protected $_val_callback = array();
     130        protected $_exclude = false;
     131       
     132        public function exclude(){
     133            $this->_exclude = true;
     134            $this->set_required(false);
     135        }
     136       
     137        public function is_excluded(){
     138            return (bool)$this->_exclude;
     139        }
    129140
    130141        public function add_validation($v = array()) {
  • orillacart/trunk/core/component.php

    r829921 r861174  
    1818    abstract static public function register_component($components);
    1919
     20    public function getMode(){
     21        return $this->mode;
     22    }
    2023    public function add_custom_error($contex, $error, $use_session = true) {
    2124
  • orillacart/trunk/core/view.php

    r817387 r861174  
    9292        Factory::getApplication()->setMessage($msg, $type);
    9393    }
    94 
    9594
    9695    public function __construct() {
     
    185184    public function display($tpl = 'default') {
    186185
    187         $app = $this->app();
     186        $app = $this->app();
    188187
    189188        if (Framework::is_admin() && !request::is_internal() && !Request::is_ajax()) {
     
    205204        static $overrides = array();
    206205
    207        
     206
    208207        $paths = array();
    209208
    210209        $com = strtolower($this->app()->getName());
     210        //search for overrides
     211
     212
    211213
    212214        if (array_key_exists($com, $overrides)) {
    213215            $paths = (array) $overrides[$com];
    214216        } else {
    215            
     217
     218
     219            $view_path = str_replace(path::clean($this->app()->getComponentPath() . DS . "views"), "", path::clean($this->_path));
     220
     221            $view_path = path::clean($view_path);
     222
     223            //add wp_content also with lower priority
     224            $paths[] = WP_CONTENT_DIR . DS . "com_" . $com . "_" . $this->app()->getMode() . $view_path;
     225            //add the template path
     226            $paths[] = get_stylesheet_directory() . DS . "com_" . $com . "_" . $this->app()->getMode() . $view_path;
     227
     228
    216229            $paths = (array) apply_filters('override_' . $com, $paths);
    217230
     
    221234
    222235        $paths = array_reverse($paths);
    223 
    224 
     236       
     237        $paths = (array) apply_filters('edit_template_paths_' . $com, $paths);
    225238
    226239        $the_path = null;
     
    242255            $path = $this->_path . "/templates";
    243256
    244 
    245 
    246257            if (file_exists($path . "/" . $tpl . ".tpl.php")) {
    247258
     
    252263        }
    253264
    254         throw new Exception("template:" . $tpl . __(" file cant be located!","com_shop"));
    255     }
     265        throw new Exception("template:" . $tpl . __(" file cant be located!", "com_shop"));
     266    }
     267
    256268}
  • orillacart/trunk/main.php

    r856599 r861174  
    33/*
    44  Plugin Name: OrillaCart
    5   Version: 1.0.20
     5  Version: 1.0.21
    66  Description: ecommerce solution for WordPress
    77  Plugin URI: http://orillacart.com
  • orillacart/trunk/readme.txt

    r856599 r861174  
    8686== Changelog ==
    8787
     88= 1.0.21 - 19.02.2014 =
     891. All templates now can be overridden by creating directory com_shop_admin/VIEW_NAME/ and/or com_shop_front/VIEW_NAME/
     90folders in the theme path or in wp-content. 
     91
    8892= 1.0.20 - 12.02.2014 =
    89931. shop manager role added.
Note: See TracChangeset for help on using the changeset viewer.