Custom Kirbytag - Informations about other tags

Hey Kirby-folks,
I am currently writing my very first Kirby-plugin and have a question. Especially concerning Kirbytags. I register my own one and in it’s html-function I want to know (1) how many tags of the same kind came before and (2) will come after the current tag.

May I asked why you want to do that?

May I asked why you want to do that?

Of course :slight_smile:
I’m making a small inline-gallery with lightbox-support. I need to inline some markup for the modal (but only once) on the page. I want it to be inlined automatically by the plugin but not more often than once and not when there is no gallery on the page.

Is this because you have used a light box that cannot be used more then once on the page without unique classnames? Would it not be easier to use one that can handle this, or one that deals with it via data attributes? I tend to use Venobox or Magnific

I think that might get a bit difficult. You can get the page object with $tag->page(), so you basically have access to everything in that page. However, while you could find all tags using regex, I’m not sure how to identify the current tag :thinking: I don’t think this is worth the effort.

I inserted it dynamically with JS. Thanks anyway!!