Lena
Lena

Reputation: 84

Is there a way to use hash mark in Phalcon route pattern?

Is there a way to use hash mark in route pattern? I tried to use backslash before hash mark \#, but no result.

My code:

use Phalcon\Mvc\Router\Group;

$gr = new Group([
  'module' => 'home',
]);

$gr->addPost("/item/view/([0-9]*)/#([0-9]*)", [
  'module'     => 'item',
  'controller' => 'view',
  'firstId' => 1,
  'secondId' => 2,
])->setName('item:view:hash');

$router->mount($gr);

Usage:

echo $this->url->get(['for' => 'item:view:hash', 'firstId' => 1, 'secondId' => 2])

gives me a correct url: /item/view/1/#2, but I receive a warning:

Unknown modifier '('

Is there a way to remove warnings, to use the hash mark in the right way? Thanks in advance.

Upvotes: 0

Views: 188

Answers (1)

ceejayoz
ceejayoz

Reputation: 180023

Nothing after the # mark is sent to the server, so including it in a server-side route doesn't do anything. The fragment/anchor is client-side only.

Upvotes: 1

Related Questions