Not logged in. · Lost password · Register
Forum: General Help and Support Plugins RSS
Add New Page with auto-id
Page:  1  2  next 
Avatar
hj #1
Member since Apr 2008 · 167 posts · Location: Lancaster, UK
Group memberships: Members
Show profile · Link to this post
Subject: Add New Page with auto-id
If you use something like the Add New Page plugin, is there any way or mechanism by which a page ID can be automatically assigned? i.e. numbered from 0001 on a sequential basis.

I need my wiki to gather 'reports', which will all be based on a fairly simple template (can probably be a namespace template), but each report needs to have a unique identifier or ID...which would be part of the page name.  i.e. in the URL, it would be something like doku.php?id=0035.  Each time a new page is made within the namespace :reports: it is automatically assigned an incremental ID number.

There's no need for a user to enter a pagename - that is NOT required.

Maybe this is a more database type of function...??
Avatar
turnermm (Moderator) #2
Member since Oct 2009 · 4673 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
See the numbering plugin.
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
Avatar
schplurtz (Moderator) #3
Member since Nov 2009 · 447 posts · Location: France, Finistère
Group memberships: Global Moderators, Members
Show profile · Link to this post
Hi,

I use something similar. Users create reports  using a form. The form creates a report page in the reports: namespace. The pagename however is not sequential, but based on date and time. for example, 20190328073421.txt when the report is submitted on march 28th 2019 at 7:34:21 AM. There is the possibility that two reports are created at the exact same date, then I think it's possible although very unlikely that one report is overwritten by the second.
About the report pagename, I remember I tried the hiddenautoinc bureaucracy field but somehow had problems with it when multiple users logged in and out.

You just need to install the https://www.dokuwiki.org/plugin:bureaucracy plugin.

Create a template page named :reports:99999999999999 (so it comes last in listings) with this content :
====== Report @PAGE@ ======

  * open date : @DATE@
  * short description : @@short description@@
  * what  : @@thing@@
  * Reporter : @USER@

===== Description ====

@@Long Description@@

===== more details  =====


------
 --- //[[@MAIL@|@USER@]] @DATE@

Then create the :reports:start page
====== Add a report ======

<form>
Action template :reports:99999999999999
Thanks "Thanks for reporting"

Fieldset "Mandatory"
Textbox  "short description"
Textbox "thing"
TextArea "Long Description" ="It's completely broken

  * It won't start
  * it seems someone smashed it
"

hidden page_name =reports:%Y%m%d%H%M%S @
submit "Send Report"
</form>

Then point your browser to http://yourdoku/reports: and create a few reports

You can get an idea of what's possible with the help of the data plugin. See https://uu6ohng9.bidule.youdontcare.com/start . User is writer password is Die2aexuil. Site is reset every 20 minutes, and will disappear on april 16th.
Avatar
turnermm (Moderator) #4
Member since Oct 2009 · 4673 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
In reply to post #1
You might be interested in a new feature, which I added to the numbering plugin:
   https://www.dokuwiki.org/plugin:numbering#automated_number…
Once set up, each new page is automatically numbered.
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
Avatar
hj #5
Member since Apr 2008 · 167 posts · Location: Lancaster, UK
Group memberships: Members
Show profile · Link to this post
Sorry, I'm a bit behind with replies.

schplurtz,

Thanks very much for that example, and the link to the sample site - interesting, and very much along the lines I'm working on.

Yes, I've started using the bureaucracy plugin and have managed to code a form which creates a new page for each submission.  As yet I've not found a way to give each page a unique sequential ID, but I have thought about using the date field to do this...because date is sequential! (and could help in searches)

I'm interested that you use the data and sqlite plugins.  What exactly do these do?  I have a feeling I need to use them, too, but am not sure what they do and how they work.  I'd like to send SOME of the data (i.e. some field values) to a database, but I don't need to send all the data (a lot of it just text).  Or maybe I don't need database functionality?  I'm just so unsure what the data (and struct/strata) plugins do?

Sorry I haven't got an example of my wiki effort online - I'm developing on a MAMP localhost. I'll see if I can move it online so you can have a squint.

cheers
Avatar
hj #6
Member since Apr 2008 · 167 posts · Location: Lancaster, UK
Group memberships: Members
Show profile · Link to this post
Myron,

Thanks for the numbering plugin suggestion.

Not sure that's quite what I'm looking for - if I understand it, it's for manually entering page numbers via a toolbar function? 

What I'm trying to do (very similar to schplurtz's example) is to create pages using bureaucracy (or similar) which are automatically given a unique ID (i.e. part of the URL) taken from values in the bureaucracy form submission.  I'm not looking to add a unique number 'on the page' itself - or if it is on the page it automagically appears without any manual user intervention.

Thanks for the suggestion, though, may yet come in useful sometime.
Avatar
turnermm (Moderator) #7
Member since Oct 2009 · 4673 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
I'm not looking to add a unique number 'on the page' itself - or if it is on the page it automagically appears without any manual user intervention.
If you create the page using the namespace template configuration, each new page will get a unique number without your having to insert it manually from the toolbar.  The number will be inserted when the page is saved.

see https://www.dokuwiki.org/namespace_templates
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
Avatar
hj #8
Member since Apr 2008 · 167 posts · Location: Lancaster, UK
Group memberships: Members
Show profile · Link to this post
Thanks Myron!

I'll certainly look into this.  I assume you mena you still have to use the numbering plugin, but if you use it in conjunction with a namespace_tempate then it will automatically insert the unique number without any manual work?

The key thing would be that the automatic number needs to be part of the URL, i.e. - /doku.php/id=automatic-number-custom-custom.php  or suchlike.

Sorry if I can't keep up with it all - trying to learn a lot at once, when time allows!
Avatar
schplurtz (Moderator) #9
Member since Nov 2009 · 447 posts · Location: France, Finistère
Group memberships: Global Moderators, Members
Show profile · Link to this post
In reply to post #5
Quote by hj:
As yet I've not found a way to give each page a unique sequential ID, but I have thought about using the date field to do this...because date is sequential! (and could help in searches)
Same here. As I wrote, using hidden page_name =reports:%Y%m%d%H%M%S @ in the form will create an YearMonthDayHourMinSec page. You can use %Y-%m-%d-%H.%M.%S or other combination. The key is to use the date in Year-month-day format because sorting lexicographically happens to automagically sort by date. There is no other combination with this property. This is an old computer hack.

Quote by hj:
I'm interested that you use the data and sqlite plugins.  What exactly do these do?
sqlite is used by data. The data plugin can only use a sqlite database. The data plugin allows to attach "data" (or "property" or "attributes") in the form of (key:value) or (key:list,of,values) pairs to a page. the pairs and the page names are stored in an sqlite database. We don't really want to know how the data plugin does that. You attach properties to a page with the ---- dataentry ---- or ---- dataentry class ---- syntax. class is just any word you want.

Once you've attached properties to some pages, you can query those properties. That's where it becomes really interesting.
The queries produce a table, or a list of pages matching some criteria.
Let's say that each report has a ---- dataentry report ---- that contains among other things an "importance" and a "what" property. "importance" varies from 1 to 3, and "what" is the pagename of whatever is concerned by the report. On the "important-report" page, you could ask for the list of pages that have a dataenrty of class "report" and a property named "importance" whose value is 3. This would always list the most important reports. Similarily, it is possible to get all the reports that concern a given page. On any page, ask for the list of report dataentries whose "what" property is the pagename. And each page will list all reports that are related to itself.

On reports:20190402123456 page
---- dataentry report ----
importance: 3
what: foo
short description: foo is ugly
open date: 2019-04-02
----
On page important-reports :
---- datatable ----
cols    : %pageid%, importance, short description
filter  : %class%=report
filter  : importance=3
----

On page foo, to list all the reports whose "what" attribute is foo
---- datatable ----
cols    : %pageid%, importance, short description,
filter  : %class%=report
filter  : what=foo
----


I have a feeling I need to use them, too, but am not sure what they do and how they work.  I'd like to send SOME of the data (i.e. some field values) to a database, but I don't need to send all the data (a lot of it just text).  Or maybe I don't need database functionality?  I'm just so unsure what the data (and struct/strata) plugins do?
I don't know the strata or struct plugin. Never used that. but the data plugin only deals with key:value pairs attached to a page. Its primary use is to create dynamic links between pages. If you need to put the data in an external database, in a format of yours, then forget about the data plugin, it is not designed to do that. It's just a great tool to create dynamic links between pages.
Avatar
turnermm (Moderator) #10
Member since Oct 2009 · 4673 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
In reply to post #8
The key thing would be that the automatic number needs to be part of the URL, i.e. - /doku.php/id=automatic-number-custom-custom.php  or suchlike.

I'm not sure what the target of this url is.  It would be a simple thing to create a namespace template which creates a url where the id is the automatically inserted number, if that is all that you need.

Edit
On reviewing your initial query, I don't think this will work for you.
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
This post was edited on 2019-04-02, 18:39 by turnermm.
Avatar
hj #11
Member since Apr 2008 · 167 posts · Location: Lancaster, UK
Group memberships: Members
Show profile · Link to this post
In reply to post #9
Thanks again, schplurtz, for detailed reply and example. Appreciated, even if I can't quite get my head around it all yet!

Quote by schplurtz:
Once you've attached properties to some pages, you can query those properties. That's where it becomes really interesting.
The queries produce a table, or a list of pages matching some criteria.

That could be useful in some situations, I can see that - perhaps where I want to place a list of pages which contain certain value matches.

Quote by schplurtz:
Its primary use is to create dynamic links between pages. If you need to put the data in an external database, in a format of yours, then forget about the data plugin, it is not designed to do that. It's just a great tool to create dynamic links between pages.

I'm not sure if I do need to put data in an external database.  I just know that I may want to 'query' or search a namespace for documents which match certain criteria.

If the data plugin is best for dynamic links, then maybe it's not for me.  Perhaps I need more of a dynamic search function?  A user might need to search the namespace for records which match CRITERIA A=RRR & CRITERIA E=XXX & CRITERIA M=ZZZ

Does that make sense?
Avatar
schplurtz (Moderator) #12
Member since Nov 2009 · 447 posts · Location: France, Finistère
Group memberships: Global Moderators, Members
Show profile · Link to this post
If the data plugin is best for dynamic links, then maybe it's not for me.  Perhaps I need more of a dynamic search function?  A user might need to search the namespace for records which match CRITERIA A=RRR & CRITERIA E=XXX & CRITERIA M=ZZZ
You're right, the data plugin can't do that. I'm not aware of a plugin that would fit your needs.

Anyone ?
Avatar
hj #13
Member since Apr 2008 · 167 posts · Location: Lancaster, UK
Group memberships: Members
Show profile · Link to this post
Yes, bit of a tricky one - I want the moon on a stick! lol

Databases often have search or 'filter' functions to query the db and throw up the results you want (see screenshot from Appgini db).  Maybe this just isn't possible within dokuwiki - and that's ok, I don't expect it to be everything I want, just trying to understand the limits of what it can/cannot do.

I may be able to get away with using bureaucracy and getting a filename concatenated from key fields (or field values). The search function in dokuwiki is pretty good and will find this kind of stuff. 

And yet it would be nice to have the flexibility that lets you list files by various criteria, i.e. values pulled from the bureaucracy 'data'.

It's fun!
The author has attached one file to this post:
filters.jpg 91.1 kBytes
You have no permission to open this file.
Avatar
pop #14
Member since Nov 2016 · 160 posts
Group memberships: Members
Show profile · Link to this post
One of my Wikis generates new pages with a unique number in each page name, hence in each URL. It does so using the bureaucracy plugin. This is the form which does it:

<form>
Action template :include:wochenblattartikel :wochenblatt:@FORMPAGE_NS@:artikel:@FORMPAGE_PAGE@-@@Laufnummer@@
Fieldset "Neuer Artikel in dieser Ausgabe"
number "Laufnummer" ++ 00
struct_field "artikel.ausgabe" "=@FORMPAGE_ID@"
struct_field "artikel.ausgabename" "=@FORMPAGE_PAGE@"
struct_field "artikel.titel"
struct_field "artikel.teaser"
struct_field "artikel.autor" !
submit
textarea "textbody" !
</form>

The line number "Laufnummer" ++ 00 displays a numeric entry field with a number that is incremented each time the action of the form is performed.

The last part in the Action line (starting with :wochenblatt: and ending with @@Laufnummer@@) constructs the full ID of the page to be written, including several levels of namespace names. The page name is a composite of the name of the page holding the form and the automatically assigned number.

The name of the generated page is a bit complicated. The page ID contains the year, the issue number and the article number with the issue of a journal which was issued each week during nearly fifty years. Each article is stored in its own page in the wiki.
Avatar
turnermm (Moderator) #15
Member since Oct 2009 · 4673 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
In reply to post #13
I've been thinking about this.  In your initial post you referred to the addnewpage plugin.  So, if you could open a newpage with addnewpage and this newpage is named as, or contains, the next unique number in sequence, would this do what you want?  If so, I might have a solution for you.
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
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:
Page:  1  2  next 
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2019-07-17, 12:48:48 (UTC +02:00)