zendframework / zend-view

View component from Zend Framework
BSD 3-Clause "New" or "Revised" License
49 stars 61 forks source link

Slash at the end of a link - Problem with Zend\View\Helper\Url #130

Open mano87 opened 7 years ago

mano87 commented 7 years ago

Hello, i have integrated two links into a template as follows.

<div class="btn-group" role="group">
    <a class="btn btn-default <?php echo ($this->url() == '/education/student-deregistration') ? 'active' : ''; ?>" href="<?php echo $this->url('education.student-deregistration', ['section' => null]); ?>">Vorklinik</a>
    <a class="btn btn-default <?php echo ($this->url() == '/education/student-deregistration/clinical') ? 'active' : ''; ?>" href="<?php echo $this->url('education.student-deregistration', ['section' => 'clinical']); ?>">Klinik</a>
</div>

And This is my route.

class RouterDelegatorFactory implements DelegatorFactoryInterface
{
    public function __invoke(ContainerInterface $container, $name, callable $callback, array $options = null)
    {
        $application = $callback();
        $application->route('/education/student-deregistration[/{section:clinical|preclinical}]', StudentDeregistrationAction::class, ['GET'], 'education.student-deregistration');
        return $application;
    }
}

Now I have the following problems:

  1. With this configuration the link /education/student-deregistration is always output with a / at the end. This is not work. What can i do?
  2. Is there a more elegant way to check the active link?

@weierophinney @RalfEggert

weierophinney commented 4 years ago

This repository has been closed and moved to laminas/laminas-view; a new issue has been opened at https://github.com/laminas/laminas-view/issues/11.