#254 ✓ resolved
Nitish Dhar

Custom Helper Issue

Reported by Nitish Dhar | May 17th, 2012 @ 08:09 AM | in 1.4.2 (closed)

Hey,

There seems to be some issue with the use of CustomHelper or to be precise, any helper in a theme - Both 1.3 & 1.4 versions.

The helper fails to read if some changed are done in the admin section or some new node is added from the admin section. It just gives an error -

Warning (512): Method CustomHelper::menu does not exist [CORE\Cake\View\Helper.php, line 179]

This is very easy to reproduce,

  1. Setup croogo 1.4
  2. Take this theme - https://github.com/nitishdhar/Bootstrap-Responsive-Croogo
  3. Install the theme & it should work.
  4. Now try adding some new node or something, now if you go back to the site, it will throw the error.

Now I am not sure, if there is some issue with my theme in particular, just see if you guys can help.

Also, one weird thing, now if this error comes, if I make some change in the CustomHelper file, the error stops. Is this being cached or something.

Thanks

Comments and changes to this ticket

  • Nitish Dhar

    Nitish Dhar May 17th, 2012 @ 08:19 AM

    Also,

    heads up, I was wrong about reproducing this is easy. This happens once in a while. I fail to connect this to anything related to the code. I mean how can this happen just sometimes. The only thing, I can relate this is to some cache problem.

    Anyways, have a look

  • Nitish Dhar

    Nitish Dhar May 17th, 2012 @ 08:56 AM

    Well, looks like, if we don't do any change also after the error comes, waiting for like 20 seconds fixes the issue. The more I word around this, the more weird it gets...

  • Rachman Chavik

    Rachman Chavik May 17th, 2012 @ 10:57 AM

    • State changed from “new” to “open”
    • Assigned user set to “Rachman Chavik”
    • Milestone set to 1.4.2
    • Milestone order changed from “111” to “0”

    Okay.

    This one I can reproduce :).

  • Rachman Chavik

    Rachman Chavik May 17th, 2012 @ 11:43 AM

    Can you apply this and test:

    diff --git a/Config/croogo_bootstrap.php b/Config/croogo_bootstrap.php
    index f4a3cfe..0002219 100755
    --- a/Config/croogo_bootstrap.php
    +++ b/Config/croogo_bootstrap.php
    @@ -67,6 +67,15 @@
        Configure::write('Config.language', Configure::read('Site.locale'));
     
     /**
    + * Setup Helper path (CustomHelper) from themes
    + */
    +   if ($theme = Configure::read('Site.theme')) {
    +       App::build(array(
    +           'View/Helper' => array(App::themePath($theme) . 'Helper' . DS),
    +       ));
    +   }
    +
    +/**
      * Plugins
      */
        $aclPlugin = Configure::read('Site.acl_plugin');
    diff --git a/Controller/Component/CroogoComponent.php b/Controller/Component/CroogoComponent.php
    index a788891..49b9534 100644
    --- a/Controller/Component/CroogoComponent.php
    +++ b/Controller/Component/CroogoComponent.php
    @@ -466,14 +466,6 @@ class CroogoComponent extends Component {
            $this->controller->set('vocabularies_for_layout', $this->vocabularies_for_layout);
            $this->controller->set('types_for_layout', $this->types_for_layout);
            $this->controller->set('nodes_for_layout', $this->nodes_for_layout);
    -
    -       if ($controller->theme) {
    -           //$helperPaths = Configure::read('helperPaths');
    -           //array_unshift($helperPaths, APP.'views'.DS.'themed'.DS.$controller->theme.DS.'helpers'.DS);
    -           //Configure::write('helperPaths', $helperPaths);
    -
    -           App::build(array('View/Helper' => array(APP . 'View' . DS . 'Themed' . DS . $controller->theme . DS . 'Helper' . DS)));
    -       }
        }
     
     /**
    
  • Nitish Dhar

    Nitish Dhar May 17th, 2012 @ 12:17 PM

    Hey Rachman,

    I have no idea how to apply the above.. Do I need to use git or something ?

  • Rachman Chavik

    Rachman Chavik May 17th, 2012 @ 12:25 PM

    Hm..

    That diff (patch above basically moves some lines (with some modification) from CroogoComponent to Config/croogo_bootstrap.php

    You can do it manually:

    • Delete the line 470-476 in Controller/Component/CroogoComponent.php

    • Manually add the following after the Locale block in Config/croogo_bootstrap.php

    /**
     * Setup Helper path (CustomHelper) from themes
     */
        if ($theme = Configure::read('Site.theme')) {
            App::build(array(
                'View/Helper' => array(App::themePath($theme) . 'Helper' . DS),
            ));
        }
    

    You could also install git since it then would be easier to pass patch files around.

    Ah, forgot to say, if you already have git, apply the diff above by saving it into a file, eg: patch.diff.
    Then using git: git apply patch.diff

  • Nitish Dhar

    Nitish Dhar May 17th, 2012 @ 12:31 PM

    Hey, I have git. Just didn't know we can pass patch files to a repo.

    Thanks, will try this and update you.

  • Rachman Chavik

    Rachman Chavik May 17th, 2012 @ 02:38 PM

    Let me know if this fixes the problem so I could commit to main repo.

  • Nitish Dhar

    Nitish Dhar May 17th, 2012 @ 02:40 PM

    Hey,

    I am out right now.. Will do this in like 4 - 5 hrs & update you.

    Thanks

  • Nitish Dhar

    Nitish Dhar May 17th, 2012 @ 02:54 PM

    Hey,

    Going out plans cancelled :) I tested, it works like a charm :) Thanks Rachman :)

  • Rachman Chavik

    Rachman Chavik May 17th, 2012 @ 03:02 PM

    awesome. i will commit this to main repo soon.

    now only the layout/helper error to track down.

  • Nitish Dhar

    Nitish Dhar May 18th, 2012 @ 02:03 AM

    Hey any chances this can come in croogo 1.3.5 ?

  • Rachman Chavik

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket

Pages