Not logged in. · Lost password · Register
Forum: General Help and Support Templates and Layout RSS
Get Data in Template instead of Mark-Up
Avatar
pdm #1
Member for 2 months · 2 posts
Group memberships: Members
Show profile · Link to this post
Subject: Get Data in Template instead of Mark-Up
Hi,

so I am currently working on a template for dokuwiki. Currently from what I've read, the only way to get my data is using the tpl_* functions, which do return Mark-Up instead of data. Which is bad in my optinion.

So there must be a way to either get the raw data or a way to provide mini templates for these functions. Can someone tell me how?

Also, is there a way to use a Template Engine like Twig?
Avatar
turnermm (Moderator) #2
Member since Oct 2009 · 4399 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
See https://forum.dokuwiki.org/post/63193
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
Avatar
peterfromearth #3
Member for 3 months · 19 posts · Location: Hunsrück
Group memberships: Members
Show profile · Link to this post
In reply to post #1
What do you want do do with the raw data?
Avatar
pdm #4
Member for 2 months · 2 posts
Group memberships: Members
Show profile · Link to this post
Just the data. The escaped database data from a specific query. Like instead of <?php tpl_action('admin')?> returning a button with what not I just want the information needed to create the button myself. I don't want any html at all. E.g. if you use <?php tpl_breadcrumbs() ?> you get "Trace" and some <spans> in there. I don't want that, I just want the data, in this case an array or whatever of the visited pages etc. So I can create the proper markup for it and style it accordingly.

Also: It's just bad practice to do it the way it currently is. (at least how I understand it)

@turnermm What exactly did you want to point out? I know that I can strip the html and get the data like that... but I'm rather not using dokuwiki than doing such a bad style of "coding". That's terrible and one should not do that at all in 2018.

EDIT: sry @peterfromearth I misread. I want to create a template. I don't want to be limited in any way by predefined markup. I just want to be consistent in my markup and use a CSS Framework so I can create a really nice responsive template. So I'm wondering how I can define what all these tpl_* methods return. If I can't, I won't use dokuwiki.
This post was edited on 2018-10-29, 18:21 by pdm.
Avatar
Michaelsy #5
Member since Jun 2015 · 567 posts · Location: Düsseldorf, Germany
Group memberships: Members
Show profile · Link to this post
I don't want any html at all

Who should retrieve or read your web pages? What is your use case?

Just the data.

What is your "data" you are writing about?

Edit I:
So I'm wondering how I can define what all these tpl_* methods return.

By deriving the existing functions, you can also program your own template-functions/methods. But that's a lot of effort, of course. Incidentally, you can replace all (default) texts with your own (that is prepared). I can not think of anything that could not be done by myself (with more or less effort).

Edit II:
Maybe you should get inspired by the starter template and the plaintext template. With less markup than there, you probably will not be able to work:
https://www.dokuwiki.org/template:starter
https://www.dokuwiki.org/template:plaintext
By Patreon.com a few eurons can be fed into the code phasers of
the DokuWiki engine. Besides, Andi's posts are worth reading.
This post was edited 4 times, last on 2018-10-29, 21:02 by Michaelsy.
Avatar
peterfromearth #6
Member for 3 months · 19 posts · Location: Hunsrück
Group memberships: Members
Show profile · Link to this post
I suppose in case of the tpl_breadcrumps function you have to rewrite the function.
In case of how the page is rendered (paragraphs, media links, images, table) you can write your own renderer (https://www.dokuwiki.org/devel:renderer_plugins).

So there is an abstraction level for the page content (wiki markup), but not for the other layout parts.
Avatar
turnermm (Moderator) #7
Member since Oct 2009 · 4399 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
In reply to post #4
@turnermm What exactly did you want to point out? I know that I can strip the html and get the data like that... but I'm rather not using dokuwiki than doing such a bad style of "coding". That's terrible and one should not do that at all in 2018.

so I am currently working on a template for dokuwiki. Currently from what I've read, the only way to get my data is using the tpl_* functions, which do return Mark-Up instead of data. Which is bad in my optinion.

The tpl_ functions do not return raw data but support the creation of templates, i.e. html, which is what 'tpl_' means.  So when you said you didn't want markup, which is what is written to DW files, and were checking out tpl_, I suggested the function which most readily outputs html from a wiki page. So what you "read" was incorrect, or more probably you didn't understand what you read.  Learn to have some manners.
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
This post was edited on 2018-10-30, 02:10 by turnermm.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2018-12-14, 04:17:36 (UTC +01:00)