Help with using Semantic Forms and Database extension together

Hello. I have a namespace 'main' (the default, obviously) which contains a couple of Semantic Forms to add new articles.
However, I'm trying to use the Database extension in a separate namespace (called KE - short for Known Errors) which adds numbered prefixes in sequential order (e.g. KE-001: ARTICLE NAME). Long story short, I want to use Semantic Forms in conjunction with this.

The Database extension uses its own special page (Special:Database) to scan for previous entries and add the next one. This is probably a long shot, but I want to pass the information/text used to create a normal article using Semantic Forms to this Special:Database page (which in turn will give it the prefix). Is this possible?

I doubt I need to use a separate namespace, so I can remove that if it makes things simpler.

I don't think I understand this question. What's an example of the kind of information that would be passed? Yaron Koren 23:37, 1 December 2011 (UTC)

The content entered into my 3 fields on my form. For example, when creating a new article using SF, first there's an article name page, whereby the user inputs the name of the article. Clicking 'Create' then takes them to the next page, which has 3 input boxes (that I set up using templates/properties/fields). After entering information into these 3 boxes and clicking continue, the article/page is created. However I want the information to be passed to the Special:Database page, rather than the default of the new page it's creating.

In terms of an example of the information that's being passed - just the MediaWiki syntax that the page composes of. For example...

Ah, okay. I just read about the Database extension - I had never heard of it before. (I should note that I find "Database" a very odd name for an extension that, as far as I can tell, just hands out unique IDs.) Anyway, maybe there's a simpler solution, that doesn't involve using Database at all - what about using the one-step process, with a page name formula that includes "<unique number>"? Yaron Koren 09:43, 2 December 2011 (UTC)

Thanks for the suggestion, that sounds more appropriate. Funnily enough the Extension:Database has just had a warning flagged on its page saying it contains a major security flaw! Anyway, had a read of the link you provided and checked the form code, but having some difficulty figuring out how to add it (not a big MediaWiki programmer, just been delegated the task). Do I need to change the #forminput to #formlink? Where should the <unique number;start=001> tag go? Thanks for your help so far. Csf90 16:05, 2 December 2011 (UTC)

Cool. Yes, you need to change #forminput to #formlink, and the form should have a line above the first "for template" tag, reading "{{{info|page name=KE:<unique number;start=001>}}}", or something like that (I didn't quite understand your naming convention.) Yaron Koren 17:44, 2 December 2011 (UTC)

Thanks, that works perfectly. Last question (I promise!) - is it possible to have both the KE- prefix as well as an article name? At the moment, each article is name KE-001, KE-002 etc. Ideally, there could be a text box to input an article title in and then it creates KE-001: Article Name. I assume this may not be possible as that would require some kind of combination between #forminput and #formlink, rather than 1 or the other. Either way, it is better now than it was before, so thank you for that :) Csf90 13:19, 6 December 2011 (UTC)

Well, that's a tricky one - you could have a formula like "KE-<unique number;start=001>: Article[Title]", but the number won't be sequential - it'll create pages like "KE-001: ABC", "KE-001: DEF", "KE-002: ABC", etc. - i.e., only the minimum number to ensure a unique page name. Having it create page names in the way you want would probably require some custom coding, unfortunately. Yaron Koren 14:47, 6 December 2011 (UTC)

Text areas becoming truncated when they contain preformatted text

I am using SemanticBundle-20110824.tgz with MEdiawiki 1.16.5.

I have created a semantic form which is working successfully.

I have a text area in the form which is not linked to a SMW property at all, but simply works as a property of the template

The content of that text area contains will sometimes contain <pre> </pre> tags so that the | and other mediawiki characters are escaped properly.

This all works fine.

The problem is that when I edit an existing page by clicking the "Edit with Form" link at the top of the page, the content of the textarea gets truncated to the first '|' even though the '|' is within a <pre> </pre> tag.

Is there any other form of escaping I can perform in the text that will allow the edit with form function to load the entire content of this field?

That's a problem, yes. It's a hack, but what you could do instead is create a template at "Template:!", and put just the single character "|" in that page. Then, instead of the pipe, put "{{!}}" in any page. That's a standard MediaWiki hack, actually, used in a variety of contexts. Yaron Koren 23:40, 1 December 2011 (UTC)

Problems Using the Upload Forms Pop-up Box

I am using SemanticBundle-20110824 and MW 1.17.0.

I have two problems: (i) when I click on Upload form, it takes me to a full page instead of the pop-up box and (ii) when I click browse nothing happens, no explorer window to navigate to the file I wish to upload).

In my error log, MW did not like Semantic Bundle accessing SMW and SF thru the old pathway instead of the newer one (SMW_Settings.php vs SemanticMediaWiki.php). Changing the includes/require_once pathway looks to have resolved problem #1. Problem #2 still persists.

I am also importing several Javascripts using importScriptURI. Commenting out the JS does not help.

--2nd Update--
Since I know little about Javascript, I wondered if the vector skin or JS implemented through the gadgets extension was coming into conflict. Disabling both did not help.

I assume the issue is Javascript problems coming from somewhere. Try looking at the Javascript console with either Google Chrome or Firefox with the Firebug extension, and see if any error messages show up there. Yaron Koren 22:02, 2 December 2011 (UTC)

Yaron, First of all thank you for the response and for all of your hard work on Semantic Forms and Semantic Internal Objects.

I had trouble finding a version of Firebug to work on Firefox 3.6. I upgraded to Firefox 8, and the problems went away. I feel a little stupid right now. Let this be a lesson to everyone, make sure you are running the latest, or at least relevant, versions.

Okay, that's good to know - Firefox 3.6 is actually only about two years old, but I guess a newer version is needed. Yaron Koren 05:44, 6 December 2011 (UTC)

Button for multiple-instance

I just looked at that extension - it's seriously old; it hasn't been updated since MW 1.15. I'm surprised that it's working for you even by itself... anyway, that's good to know. Yaron Koren 03:20, 6 December 2011 (UTC)

Values from namespace - Main namespace

Hello, just for confirming and improving documentation. In a Spanish MediaWiki (Main -> Principal namespace), I see that values from namespace=Principal is not working. It works values from namespace= though. --Toniher 10:27, 7 December 2011 (UTC)

Thanks for letting me know about that - I just checked in a fix in SVN. Yaron Koren 19:45, 7 December 2011 (UTC)

Automatically lowercase name of page created with form?

Is it possible to automatically lowercase the name of a page created with a form? I tried putting the "lc" (lowercase) magic work around "forminput" in my form and it didn't automatically lowercase the name of the page. Thank you so much
162.89.0.60 16:56, 8 December 2011 (UTC)

It is not set and therefor its the default value (true), however, I may have been unclear. So I have a form that allows people to create a new page. They enter the name of the page they want to create and press "submit" and are taken to the form to create the page. Some people choose to capitalize every word in the page name (e.g., My Awesome Page"), while others choose to lowercase every word in the page name (e.g., "my awesome page"). I was hoping there was a way to automatically lowercase any title a user chooses so that "My Awesome Page" would turn into "My awesome page," thereby following the standard mediawiki page name formatting. There is a way to do this with every other form field by using {{lc:string}}, but not when creating the name. 162.89.0.60 21:21, 8 December 2011 (UTC)

Oh, I see. I don't think there's a way to do that, and I'm leery about adding that kind of functionality in, because so far SF is pretty fastidious about not modifying people's inputs. (I assume the "lc" call you're doing for other fields is in the template, i.e. it affects the display of those fields, but not the underlying wiki-text.) Anyway, what about words that should be capitalized, like proper nouns and such? Yaron Koren 00:23, 9 December 2011 (UTC)

That's actually a good point. My wiki compiles camp and after school games, so there aren't a lot of page names with proper nouns. Thanks for being such a rock star developer by the way. I just noticed recently that you are responsible for like 90% of the mediawiki extensions I use!

Hey, thanks! I'm glad you're making good use of all the SMW-based functionality. Yaron Koren 04:51, 9 December 2011 (UTC)

Auto create page name, page property, link updates?

I don't think this is possible, but...? I use a form to create a page from the form data. I understand I can I have a field with a Page property to allow links to other pages. If the page doesn't exist(red link), I can create the new page. Here is the question, I would manually have to go back and update the page links. Is there a way I pass them back to the original page where they occurred in the field? Otherwise, I would continue to have red links to pages that don't exist. Or would I be better off listing a query of association with a link to create the new page with the linking association? Use Categories to make the association? Thanks Hutchy68 22:37, 8 December 2011 (UTC)

I don't understand this. Could you use an example? Yaron Koren 00:26, 9 December 2011 (UTC)

Thanks for replying Yaron - I Create a page with fields First and Last Name, say the page is "John Smith (unique#)" On John Smith's page there is a 'Page Field' called - "Person(s) associated with" which contains, Mark Jones, Tom White and Steve Black. So I click "Mark Jones" but the page name after creation would be "Mark Jones (unique#)" because the form creates the page name from the first, last and <unique number> variable. Under John Smith's page, the field still contains "Mark Jones" and not "Mark Jones (unique#)" I have to use the unique number because I could have more than one person with the same name. Hutchy68 02:31, 9 December 2011 (UTC)

Oh, I get it. No, there's no automatic way to do that kind of modification. And since this is a symmetrical relationship, I can't think of a query-based solution either. Maybe the right answer is to not link to such pages until they've already been created. Yaron Koren 04:49, 9 December 2011 (UTC)

My solution to this problem is to temporarily create the properties in an ephemeral Special:RunQuery form, then use that data to populate temporary properties that will automatically create the pages. The pages will have a property that links back to the page they came from - in Hutch68's example, the property would link back to "John Smith (unique#)" in a child-to-parent or many-to-one relationship. Then, "John Smith (unique#)" can use queries to find the pages pointing to it, and the query results can be used to populate the properties on its own page!

I have not progressed far enough in my own use-case to test this strategy, but since Hutchy68's use-case is simpler than mine, I suspect it will work for Hutchy68.

In my own use case, each page gets its own unique ID number that is determined in the form with this "page name=" parameter:

Prefix<unique number;start=1>

So, when setting up my own redlinked properties, I do Temporary autocreate property::Something. But, I don't know what "Something" should be, since I think it is ignored in a form that already has a "page name=" parameter (I haven't tried it yet). In addition, I don't see how the entered form data gets from the form, through the autocreate property, into the new page. Is this something Semantic Forms could do?

How I plan on using it is letting people paste a CSV formatted text file with all of their data into a Special:RunQuery form. Then, the template for the Special:RunQuery form parses the CSV text, queries to see if any of the data has already been entered, and then presents separated lists of data that is already entered, and data that needs to be entered. The "data that needs to be entered" part - I was hoping - could be automatically created with the Semantic Forms red link autocreate feature. Since it does not appear that any of the data can be pushed into the new autocreated pages, I'm going to probably just going use #autoedit links with the data formatted into the preload query strings. Then, the user may have to click a few hundred times to create all the pages they want to create, but that's still an improvement over manual data entry.

Eventually I'm going to have to learn to get comfortable with adding features like this to Semantic Forms (or create a new extension or a bot to do it). For now, it's over my head, but if I get a few months of down time to do nothing but play with it, I'm sure I could do it.

What do you think? Have I evaluated the capability of the Semantic Forms autocreate features correctly, or did I miss something? Will any of this work for you, Hutchy68?

My solution to this problem is to temporarily create the properties in an ephemeral Special:RunQuery form, then use that data to populate temporary properties that will automatically create the pages. The pages will have a property that links back to the page they came from - in Hutch68's example, the property would link back to "John Smith (unique#)" in a child-to-parent or many-to-one relationship. Then, "John Smith (unique#)" can use queries to find the pages pointing to it, and the query results can be used to populate the properties on its own page!

Badon, you're talking about using a template to run a query, populate the data(using internals?), then passing it to the new page? I think you might run into server, jobs issues as properties are usually done in chunks. Does this sound right Yaron? Hutchy68 22:17, 8 January 2012 (UTC)

What I ended up doing is bypassing the forminput and use a formlink. With a query to list the property associated pages, and a formlink with a passing of information to the new page, which I do in a popup with a partial form for the base information, it seems to work well. The new page is created with a prefilled page link back to the page I used to create it. I have not tried the extension Data Transfer yet. Which I think will take me back to square one in this method as my page is created with a <unique number> in the page name.

My question back to Yaron would be, how is the unique number called/created? I can use start=0001 or whatever in the page name. There has to be a variable being stored in the database for each page created with a similar name. John Smith(01), John Smith(02), John Smith(03), but John Henry Smith(01), starts over with 01 for each new page name. It would be extremely useful to have the <unique number> available to a form field. This way a page could be assigned an ID# in a field and it could then be passed to a pagename so I could have John Smith(ID432), John Smith(ID989), John Smith(ID1004), and John Henry Smith(ID343).

I tried a rudimentary PageID extension, but the problem is the page doesn't actually exist, so the PageID is NULL. I could call it in a field just fine, add ID in front of it, but the forms field was being filled with IDNULL, instead of ID159 for example. I'd even be happy with being able to call the last pageid and adding 1 to it and using it. There has to be a way to put a unique number into a field automatically on page create without having to physically enter it. Perhaps a preload of a counting template's variable, but I could see a break in the system with one small error. Hutchy68 22:15, 8 January 2012 (UTC)

There's no variable being stored in the database - the code just starts at the first number and increments up until it finds a page that doesn't exist yet. So if there's John Smith(01), John Smith(02) and John Smith(03), and then John Smith(02) gets deleted, the next page created by that form will get named "John Smith(02)". Yaron Koren 23:21, 8 January 2012 (UTC)

Display data from form fields on a page in a different order than they are displayed in the form?

I was wondering if it was possible to have a page populated with data from a form, but the data is not in the same order as it was displayed in the form. So the form would ask some one to enter the date, the description, some tags, and a picture, but when displaying data on the page, the order could be changed to date, picture, description, tags. I ask because I would like to use your extension header tabs. I would like for the pictures to be displayed on a separate "pictures" tab. That would mean that in the form, the picture upload field would have to be either at the bottom of the page or before the <headertabs /> code. I would like the picture upload field to be right under the description so that its intuitive to users that the pictures are relevant to the description, but in the page, it would be nice if the pictures were actually at the botttom of the page so that they would be on their own tab all by them self. I hope this makes sense. I know you're dealing with Referata stuff, but thanks for all the time you spend answering our questions.
70.112.0.226 02:11, 9 December 2011 (UTC)

You might be able to do this by displaying that data via a query, instead of directly showing it - it all depends on your data structure. This question might be better asked at the semediawiki-user mailing list, with the form and template code listed, since the answer might be complex. (Also, Header Tabs isn't my extension, though I help maintain it - another guy wrote most of the code.) Yaron Koren 04:56, 9 December 2011 (UTC)

Image not showing after upload

Unfortunately, the solution was done for the person in the above example and so I have no idea what fixed it.

My problem: Image uploads, shows the file in the form (confirmed that File exists in Special Pages) but won't display image on page.

Not only have I searched the archives here, I've gone through other forums and the mailing list and been trying everything possible to see if its Data-types, Properties, Internal Objects...but I'm over my head and would really appreciate some direction.

I don't know - I've never heard of such an error before. Maybe your copy of SF has been modified in some way? I would try upgrading to the latest version of SF and see if you still get it. Yaron Koren 12:15, 16 December 2011 (UTC)

Looks like we're making progress. After upgrading from Semantic Forms (Version 2.2.1) to Semantic Forms (Version 2.3.2), it appears that the extension's SF_UploadWindow2.php file was able to process all the way to line 1117:

Fatal error: Cannot redeclare class SFUploadWindow2 in (path to MediaWiki)/extensions/SemanticForms/specials/SF_UploadWindow2.php on line 1117

Your sarcasm confuses me. Anyway, I don't know what's causing the error - my only theory is that Semantic Forms is somehow getting included more than once, either in LocalSettings.php or via some other extension. Yaron Koren 22:13, 18 December 2011 (UTC)

Your observation about the extension getting included more than once, however, gives me an idea of where to try and trouble-shoot. Hopefully I'll have time to do that later today. Will report back any results worth reporting on.

Template in a template

Hi,

This extension is very useful, but sometimes, for a non english speaker, it's not easy to understand. For exemple, is it possible to have multiple instances of a template (tag multiple) in another template ? Thanks for the help. Marc

The page itself in this case would use 4 templates. A main one called {{Create person}} with 3 variables, {{{Main}}}, {{{Add address}}}, and {{{Contact info}}}, which actually call a template themselves. Think of the {{Create person}} template as the main template and the others all as subtemplates. You can control the way the the information is presented by the {{Create person}} template by calling the variables in any order.

The field {{{Contact info}}} actually calls the template {{Contact info}} 3 times, providing it each time with a new set of variables for the Contact info. You will be limited in presentation of the multiple fields because you are calling them multiple times right after each other. Use something like:

* {{{Contact type}}} - {{{Contact}}}

Which will put them in a bulleted list. Hope this helps. Hutchy68 18:44, 20 December 2011 (UTC)

Thanks ! This is not easy to understand, but it works. Marc 13:25, 21 December 2011 (UTC)

Thank to have take the time to explain this feature with a clear example. I can see where was my problem : I didn't knew how to use the templates in this case, and now I think I understand how it works. Marc 17:07, 21 December 2011 (UTC)

One little thing that tripped me up: the 'for template' tag has to come AFTER the 'holds template' field in the form definition. Works great though!

Example of a field for a dropdown choice

I have read, re-read, read again and searched for examples and I am throwing in the towel. All I want is a dropdown for a field with a Male or Female choice to that field. Hutchy68 22:23, 19 December 2011 (UTC)

In case anyone needs this, I figured it out finally with way too many trial and errors.

Yaron, great extension, but there is a need for more examples and the proper format of how to put together a field. In other words, what goes where and when. I was calling input type too soon in the field and didn't even realize it had to be at the end until 50 edits later. Hutchy68 17:26, 20 December 2011 (UTC)

Hi - the order of the parameters shouldn't matter; you can have the "input type" parameter first. (After the field name, that is - i.e., "Gender", which always has to go first - maybe that was the issue?) In any case, if you just want a dropdown, you could also just have "input type=dropdown|values=Male,Female". Yaron Koren 18:04, 20 December 2011 (UTC)

Hi Yaron - it kept throwing sometype of a parser error at the top of the page, which didn't disappear until I placed input type at the end. Let me see if I can replicate the error again and post it. I'll have to roll back the form to previous versions as I tweaked it a little more. Next question is how do I pass that value to another template in the form which I need for a #switch on what #ask to call? I think there is an extension that allows for global variables in a page shared between all templates used in the page. Thanks Hutchy68 19:01, 20 December 2011 (UTC)

That's the Variables extension. You could also use #show, if you're storing the fields via Semantic MediaWiki. Yaron Koren 19:10, 20 December 2011 (UTC)

Yes, but I need to pass the value to another field. I tried #show, but my syntax was probably wrong. If I have Gender in one template, I need to pass the value, Male or Female, to another template's field for use of the #if or #switch function to work. I need to call another template depending on whether the Gender field is Male or Female. I thought I could pull the value from the Gender property specific to the page, like a query, but I keep getting the word, Gender and not the actual value of Male or Female of the Property Gender for the page. Can I use #show to set the value of the hidden field in the template I need the variable to pass to? Hutchy68 20:28, 20 December 2011 (UTC)

Oh, I get it. The "show on select" parameter might work for that. (It works with dropdowns, but not with comboboxes.) Yaron Koren 22:30, 20 December 2011 (UTC)

Thanks Yaron but I went with the Global Variable option in the Variables extension. Much easier and I need a few fields with Global Variables. Hutchy68 21:27, 21 December 2011 (UTC)

Empty fields and result on Template variables

Started a new topic. Hutchy68 00:36, 22 December 2011 (UTC)
Off topic of this section, but one thing I did notice, if a field is left blank, it isn't populated into the template as a blank variable. Like:

{{My template
|Variable1=This
|Variable2=
|Variable3=That
}}

If Variable2 is left blank, it just doesn't populate it into the page. Is this a default action of semantic forms extension? Hutchy68 21:27, 21 December 2011 (UTC)

I don't understand the issue, but no, Semantic Forms has no effect on the display of templates. Yaron Koren 23:43, 21 December 2011 (UTC)

I know it has no effect on the template if the variable isn't there. Here is what I mean:

This is what is populated into the page using a form if a field for Variable2 is left blank.
{{My template
|Variable1=This
|Variable3=That
}}
Variable2 is completely ignored so it isn't written to the page.
Semantic Forms seems to only write the variables with a value and ignore the rest.
Which is fine as it has no effect on the template. The template assumes the value is null.
If I was using a standard page wiki markup, I would use this when Variable2 is null.
{{My template
|Variable1=This
|Variable2=
|Variable3=That
}}

Using this method I can us a #if statement to check for null of Variable2, then assign set a variable to it. The form method is fine for strings, text, etc. But...If my variable is a page name and I use Unknown as a default, I could literally have multiple pages all pointing a one page called Unknown. It also cause issues if the variable value is missing as if I call a variable not on the page, it uses {{{Variable2}}} as the value because it is missing from the page. Hutchy68 00:36, 22 December 2011 (UTC)

Okay, I get it. There's definitely a case to be made for including field names even if their value is blank, but as a practical issue I don't think it matters: I think templates treat fields/parameters the same whether they're there but blank, or not there at all. Yaron Koren 01:55, 22 December 2011 (UTC)

They do and they don't. If the variable name is there and it ='s nothing it is treated as a null value. The variable is noted in the system as a null value and you can test with the #if or #switch, etc. If the variable is not on the page as variable= then the template can't call the variable and assumes it is null. The flexibility of being able to call the #if and #switch, or other parser functions of a variable is unavailable easily without the variable= on the actual page calling the template. I haven't looked at the code for Semantic Forms extension, but I am guessing it processes the variable values by looking for a field together with a value. Wouldn't it be just as easy to list the variables with the values, whether empty or not. I'm guessing it is building the page, pipe(|) field name, adds =, then value, line break, pipe(|), then starts over with some type of echo statement. Good upgrade ??? Has my vote. Hutchy68 02:46, 22 December 2011 (UTC)

In the template, have you tried calling "{{{field|}}}" instead of "{{{field}}}"? I'm pretty sure that works well in either case. Yaron Koren 04:40, 22 December 2011 (UTC)

Thanks Yaron! my template syntax got sloppy over the past few years. I completely forgot it is better to use the | symbol in the field calls. Works like a charm so I withdrawl the need to put all variables in a page! Hutchy68 14:32, 22 December 2011 (UTC)

Create a template - Add field button does not add another field

Hello!
Great template, but when I push the "Add field"-button in the "Create a template"-page, another field is not appearing - nothing really happens (i dont even get a javascript error-message). Any idea why this happens?

What versions of MediaWiki and Semantic Forms are you using? Yaron Koren 16:32, 21 December 2011 (UTC)

How you can to define the output values in semantic forms.
I would like to have as output value "de", but in the form I want to see the word "German".
How is that possible?
I thought maybe:
* [[Allows value:: de|Deutsch]]
But that didn´t work :-(
Can someone help me?

Currently, the only way to do it is with Javascript - see here. Yaron Koren 16:25, 23 December 2011 (UTC)

Create another page via popup and retrieve the name?

Would it be difficult to open another form in a popup to create a new page and retrieve the name onto a field? Something like a mix of the uploadable option of the field tag and the popup option of the forminput tag.

That way we could, for example, have an Author and Book forms and easily generate one (or multiple) author pages from a book form.

No - there's no way to have a popup form populate a field within the form from which it's called. I would recommend instead having users first create the book, and then having the red links for authors that don't have a page yet point to a form, using "Has default form". (It might be nice to be able to set red links to point to a popup form, but that's not possible yet.) Yaron Koren 13:41, 26 December 2011 (UTC)

Delete/Edit with FormInput?

I am looking to replicate the edit/delete functions from mediawiki tabs on the page. It is possible to use forminput? sending me using &action=Edit or &action=Delete???

SemanticForms and Flagged Revisions

Extension:Flagged Revisions adds a "Sight this revision" box next to the minor edit and watch this page boxes above the summary field. However, this doesn't appear on the form, because there is no standard input thing to define it—at least, not that I can see in the docs.

Is there a way to add it to the form, or is support planned in the future? I know the extensions are separate, but it's the one thing that annoys me about the forms, and I'm sure there are many wikis that use both SF and FR that would be grateful. Dendodge 23:53, 30 December 2011 (UTC)

Oh, I didn't know about that checkbox. Hopefully I can look into that soon-ish, or someone else can. Yaron Koren 23:36, 2 January 2012 (UTC)