I am trying to add link to static page
`<a href='{{ "administer/catalog-items_item"|page({ item_id: item.id }) }}'>test
</a>`
when I click on test it clicked URL its not working correctly, it seems twig is not parsing static page content. or more likely static page is not using twig engine to parse its code.
is there any way to work this out? how can I add dynamic link generated by twig to static page content.
You can not add twig markup
into the static page
content.
However if you want ot use
twig markup
you can use it using snippets.
Let me show you, how you can add that dynamic link using snippet.
1. Create snippet
OR just use code and add it
file : /themes/your_theme/partials/static-snippet.htm
description = "test snippet"
[viewBag]
snippetCode = "test-snippet"
snippetName = "Test Snippet"
==
<a href={{ "ajax"|page }}> click me </a>
Note : please change code according to your need. <a href='{{"administer/catalog-items_item"|page({ item_id: item.id }) }}'>test</a>
for your item id you need to make variable which id you want to show in snippet. or from partial add component and get it from there there.
2. Add snippet to the your static page
OR just use code and add it
file : /themes/your_theme/content/static-pages/static-page.htm
[viewBag]
title = "static-page"
url = "/static-page"
is_hidden = 0
navigation_hidden = 0
==
<figure data-snippet="test-snippet"> </figure>
Note : here you just need to use <figure data-snippet="test-snippet"> </figure>
and paste it where you need to show link.
1. Add property
Code
description = "test snippet"
[viewBag]
snippetCode = "test-snippet"
snippetName = "Test Snippet"
snippetProperties[itemId][title] = "Item Id"
snippetProperties[itemId][type] = "string"
snippetProperties[itemId][default] = ""
snippetProperties[itemId][options][] = ""
==
<a href={{ "param"|page({ id: itemId }) }}> click me {{itemId}} </a>
2. Click ok snippet and add desired value. and then again add new snippet and add new value as much as you like
Code
[viewBag]
title = "static-page"
url = "/static-page"
is_hidden = 0
navigation_hidden = 0
==
<figure data-inspector-id="inspectorid-447952244549" data-property-itemid="10" data-snippet="test-snippet"> </figure>
if any doubt please comment.