Navigation strips (changes) link needed by form in modal window

edited March 2012 in Feature Requests
I have a modal window contact form that is controlled by javascript & ajax and accessed by a link to the ID of the form. eg, href='#formID'

FuelNav won't allow this link address -- in fact, it turns it into href='sitename/formID'

If I hardcode the link (not use the fuel navigation menu), then the contact form works as intended.

Any similar javascript will have this issue

The suggestion is to allow for such links in future versions

Thanks

Comments

  • edited 11:56PM
    If you change line 858 of the Menu class to something like this:
    $location = (preg_match('/^#/', $val['location'])) ? $val['location'] : site_url($val['location']); $str .= '<a href="'.$location.'"'.$attrs.'>'.$label.'</a>'; Does it fix your problem?
  • edited 11:56PM
    Close -- and that helped! I got it working.

    For anyone else who may need this, the line to replace is a call to the anchor subroutine, and the appropriate code turned out to be

    $location = (substr($val['location'],0,1)=='#') ? $val['location'] : site_url($val['location']); $str .= '<a href="'.$location.'"'.$val['attributes'].'>'.$label.'</a>';


    Your suggested change is likely also needed for completeness (in what I have it is about a dozen lines further down)

    There also needs to be a change to the navigation model in the on_before_clean callback to not strip the #. What I now have is

    function on_before_clean($values) { if (empty($values['nav_key'])) $values['nav_key'] = $values['location']; // if the path is local, then we clean it if (!is_http_path($values['location'])) { // check for # and don't delete it if there if ( !(substr($values['location'],0,1) == '#') ) { $values['location'] = str_replace('/', '___', $values['location']); $values['location'] = url_title($values['location']); $values['location'] = str_replace('___', '/', $values['location']); } } return $values; }

    It would likely be safer to keep some of the other tests, but this was expedient.

    Thanks.
  • edited 11:56PM
    Strange, this seems to work for me without any problems.

    Nav settings: http://dev.whats-on.co.nz/assets/images/grab.jpg

    Click 'test' in the left of the footer here: http://dev.whats-on.co.nz

    Apologies if I've misunderstood.
  • edited March 2012
    I don't know -- when I did what you did, the # never make it into the table, and then even when I changed the navigation model to get the # in, the menu class was stripping the # when the link was created.

    The line numbers didn't match up well. Perhaps someone had already posted a fix that I missed.
  • edited 11:56PM
    The latest version already had the model fix in place but sounds like the Menu class fix should still be posted to the repo.
Sign In or Register to comment.