1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

manipulate template

Discussion in 'XenForo Development Discussions' started by ragtek, Nov 10, 2010.

  1. ragtek

    ragtek Guest

    Anybody found a method, to change automatic the template?

    For my own Board, i'm creating a copy of the template, manipulate it and use the manipulated template with overwriting the whole controller method.

    For example:
    PHP:
    class Ragtek_DeveloperTools_ControllerAdmin_AddOn extends XFCP_Ragtek_DeveloperTools_ControllerAdmin_AddOn
    {
        
    /**
         * overwrite the original index action, so i can use a other template because of the export link
         */
        
    public function actionIndex()
        {
                
    $addOnModel $this->_getAddOnModel();
                
    $viewParams = array(
                        
    'addOns' => $addOnModel->getAllAddOns(),
                        
    'canAccessDevelopment' => $addOnModel->canAccessAddOnDevelopmentAreas()
                );
                return 
    $this->responseView('XenForo_ViewAdmin_AddOn_List''addon_list_ragtek'$viewParams);
        }

        public function 
    actionCreateZip()
    as you see i'm using 'addon_list_ragtek'instead of addon_list

    But IMHO that's a very ugly way for this.

    A other way would be to try a str_replace of the output, but that's IMHO too much overhead and also very ugly.
    Anybody know a better way?:)

    That's why we need something like TMS. PLS PLS Kier;)
     
    Yoskaldyr likes this.
  2. Yoskaldyr

    Yoskaldyr Well-Known Member

    +1
     
  3. Jeremy

    Jeremy XenForo Moderator Staff Member

    If you edit the template and do this it should work:
    PHP:
    <?php

    class myClass extends xenClass
    {
        public function 
    actionIndex()
        {
            
    $addOnModel $this->_getAddOnModel();
            
    $xenView parent::actionIndex();
            
    $xenView->params['canAccessDevelopment'] = $addOnModel->canAccessAddOnDevelopmentAreas();
            return 
    $xenView;
        }
        
    // OR (depending on if they have subView
        
    public function actionIndex()
        {
            
    $addOnModel $this->_getAddOnModel();
            
    $xenView parent::actionIndex()
            
    $xenView->subView->params['canAccessDevelopment'] = $addOnModel->canAccessAddOnDevelopmentAreas();
            return 
    $xenView;
        }
    I'm not entirely sure of what you were attempting to add, but the idea is there.
     
  4. ragtek

    ragtek Guest

    Yes, i know that i can do this, but i can't add new elements (text, link, etc...) WITHOUT editing the template manual.
     
  5. Jeremy

    Jeremy XenForo Moderator Staff Member

    Oh. Sorry, I misread your original question.
     
  6. ragtek

    ragtek Guest

    ThatÄs what i'm talking about: export.PNG

    Is it possible to add this "link => "Zip erstellen" without editing the template manual, or overwritung the action and using a complete different template?
     

Share This Page