I need to know the current page url in a shortcode

17 views
Skip to first unread message

gian paolo ciceri

unread,
Mar 16, 2017, 8:28:13 PM3/16/17
to nikola-discuss
Hi all,
sorry for the newbie question, but I need to know what have I to do to get the current page (story) url in a shortcode that I'm calling from this page itself.

I've tried with something like abs_link(permalink), but with no success. It seems that "permalink" is None.

Shouldn't be a variable in GLOBAL_CONTEXT?

Thanks for your patience.

Best Regards
/gp



Chris Warrick

unread,
Mar 18, 2017, 1:44:09 PM3/18/17
to Nikola—Discuss
permalink is part of the local context of every page. Because of how
shortcodes work, Nikola cannot offer `permalink` there. However, you
can use the post object to do what you want — the method is
post.permalink() .

Note that the latest version has a bug — this does not work with the
reST compiler, unless this one-line patch is applied:
https://github.com/getnikola/nikola/commit/f0cd6c6f9ea6c05ef3f9eb783a139e62f48075b3

--
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16

gian paolo ciceri

unread,
Mar 20, 2017, 12:57:48 PM3/20/17
to nikola-...@googlegroups.com
Thanks!

It works. One-line-patch. Yes.

Regards
/gp
"Antiochus, when he was Ephor, hearing that Philip had given
Messenians their land, asked if he had also provided them with the
power to prevail in fighting to keep it." (Plutarch, Sayings of
Spartans)


gian paolo ciceri
mobile : ++39 348 5435450, skype: gpciceri
> --
> You received this message because you are subscribed to a topic in the Google Groups "nikola-discuss" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/nikola-discuss/xSAY1aNriJ4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to nikola-discus...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages