Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optional blocks #6

Open
glensc opened this issue Jan 4, 2012 · 11 comments
Open

optional blocks #6

glensc opened this issue Jan 4, 2012 · 11 comments

Comments

@glensc
Copy link

glensc commented Jan 4, 2012

it would be useful to have optional blocks:

say if some field is not defined, but in template it includes some markup, it would create broken/partial links:

| Parent Service          | [[support:@@!parent service@@]] |||

in case my page does not define "parent service" i get rendered partial link:

| Parent Service          | [[support:]] |||

perhaps such markup:

#if @@!parent service@@
| Parent Service          | [[support:@@!parent service@@]] |||
#endif
@kasimon
Copy link

kasimon commented Feb 10, 2012

The availability of optional blocks would be very nice, but your Problem can be solved with custom aliases too. Define a _support alias in the admin interface with type page and prefix :support: and use the field "parent service_support".

@glensc
Copy link
Author

glensc commented Feb 11, 2012

your suggestion seems nice, but can't get it to work any way, tried all combinations i could think of

  • @@parent_service_support@@
  • @@!parent_service_support@@
  • [[@@parent_service_support@@]]
  • [[@@parent_service@@_support]]
  • [[!@@parent_service_support@@]]
  • [[!@@parent_service@@_support]]

@kasimon
Copy link

kasimon commented Feb 20, 2012

Sorry for not replying earlier, I got no notification from github. Your have to write the suffix th the datatemplateentry:

---- datatemplateentry ----

parent_support: whatever

and in the template itself only use @@parent_support@@, dokuwiki will create the link itself.

@glensc
Copy link
Author

glensc commented Mar 14, 2012

are you sure what are you saying? as afaik formatting from ---- datatemplateentry ---- has no role at all with datatemplate plugin (as it is with data plugin), it is always rendered with template itself, so filling _support suffix in datetemplateentry has no point, it needs to be filled in template

i mean did you test what are you suggesting here? i just can't get it work like you say

closest thing i get, is to fill in template:

 | Parent Service          | @@!parent@@_support |

so it with such dataentry:

---- datatemplateentry service ----
template   : tpl_issue6 
Service Name_page  : scms
parent_support : portal
----

it can print "portal_support", but as text, not link

@glensc
Copy link
Author

glensc commented Aug 16, 2012

can you review my wish again and say what can be done here?

@ccl
Copy link
Owner

ccl commented Aug 17, 2012

Sorry for not replying earlier. I did not feel like optional blocks belong in the plugin. I checked if other plugins could maybe provide that possibility (e.g. the macros plugin), but never tried if it really works. However, kasimon is partially right: the plugin supports the default http://www.dokuwiki.org/plugin:data#type_aliases, but only when using @@abc@@ placeholders (not @@!abc@@).

I have the following suggestions and hope that one of them will work for you:

  1. Use two different templates, one with and one without the @@parent@@ placeholder, and then switch between them accordingly.
  2. Use the _page alias:
  • In the datatemplateentry:
    parent_page: support:portal
  • In the template:
    | Parent Service          | @@parent@@ |||

This will result in an empty table cell but no broken links if no parent is defined.
3. I thought that one could get rid of the whole table row by defining a new type alias as follows:

  • Type: wiki
  • Prefix: | Parent Service | [[support:
  • Postfix ]] |||

But it turns out that the current implementation of datatemplate does not support custom column types, and the data plugin does not seem to accept table syntax in a type definition. Hence this solution would require some investigation and programming.

@ccl ccl closed this as completed Aug 17, 2012
@ccl ccl reopened this Aug 17, 2012
@glensc
Copy link
Author

glensc commented Aug 17, 2012

yeah, different template is not good way to go, as "parent page" is not only optional field i want to have, i just made sample with one field...

@ccl
Copy link
Owner

ccl commented Aug 20, 2012

What about defining the whole table row inside the datatemplateentry?

---- datatemplateentry service ----
template : playground:tpl_issue6 
Service Name_page  : scms
parent : |Parent support|[[support:test]]|
----

@glensc
Copy link
Author

glensc commented Aug 20, 2012

i don't understand, this is supposed to work with current code? can you show both page and template in that case?

@ccl
Copy link
Owner

ccl commented Aug 20, 2012

It should. I have it working here: http://129.194.119.140/wiki/playground:dt_test

glensc added a commit to glensc/dokuwiki-plugin-datatemplate that referenced this issue Aug 20, 2012
@glensc
Copy link
Author

glensc commented Aug 20, 2012

added some parser can be used like:

====== @@service name long@@  ======
| Service                       | [[support:@@!service name@@]] |||
| Description                   | @@service name long@@ |||
{if @@!parent@@}
| Parent Service                | @@!parent@@ |||
{/if}

however it has problem with newlines, no matter how i try it will either lose needed newlines, or add extra newlines, so that the table gets broken (extra newline adds new table, or missing newlines make next row being column to previous row)

as it should support combinations of:

  • one if between able rows
  • several consequtive if statements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants