Summary: Talk page of
Fox
Back to Fox
Please leave latest comment or question at the top of this section:
Replace without a blank line
When i try to replace the content beetween two anchors (or two words), as in the fox form below, it creates a blank line beetwen the anchors.
Is it normal ? And is there a way to have no blank line and no space beetwen the anchors ? Benji January 27, 2012, at 07:39 AM
(:fox sup foxaction=replace target={$FullName} put=marktomark mark=[[#a]] endmark=[[#B]]:)
(:foxtemplate "":)
(:input submit post "Supprimer":)
(:foxend sup:)
[[#A]]test[[#B]]
Result
[[#A]]
[[#B]]
Right now I am not sure why I added newline characters when doing a "mark to mark" replace, so i am unsure if this is a bug or feature! You can remove these by hacking fox.php: edit ca. line 866, replacing this line:
$text = substr_replace($text, "\n".$template."\n", $ipos, $ilen); break; }
with this:
$text = substr_replace($text, $template, $ipos, $ilen); break; }
You notice the "\n" newline characters are removed. Please let me know if anything breaks with this hack! It is specific to fox replacement mode "put=marktomark" - HansB February 02, 2012, at 03:38 PM
Ok. In fact, i just already did this on the fox.php, and it works, and for the moment i did not see any problems. Benji February 04, 2012, at 02:17 AM
How to update PTVs on two different pages
I have a fox form that creates a new page based on a template, and sets various PTVs on that new page. But I would also like to update a PTV on the EditSource at the same time. Is this possible? I have tried several things already, including (:foxptv:), but I must be doing something wrong.
Let's assume I have a ptv on the EditSource called "Status", that I would like to set to "Complete" upon submit... Is there a way to do that with foxptv, and if so, what is the syntax?
BTW, FOX is a wonderful cookbook!!
Thanks! -Michael
To add content to Target1 using Template1 page and update a PTV ptv2 on Target2 please try something like this:
(:fox formA:)
(:foxadd target=Target1 template=Template1:)
(:foxptv Target2 ptvfields=ptv2:)
(:input submit post:)
(:foxend formA:)
i.e. you need to use foxadd and foxptv, not markup for adding content in the fox form directive. - HansB January 24, 2012, at 01:06 PM
I realize this is not the place to start this discussion, but where would I go to get some advice on writing my own recipe? I'm considering writing a plugin to turn tables into simple spreadsheets. Even just a basic total up rows or columns, basic math between cells and only computing left-to-right and top-to-bottom. This would greatly enhance our wiki. One of the main things I want to know is how to decide on markup that would be usable and not conflict with another recipe.
Like:
name the table: || name=table_name
name a column: put this in the header row (-col Amount-) or (+col Quantity+)
name a row: (-row Totals-)
reference a cell: $<table_name.col_name,row_name> or $<.col_name,row_name>
reference a column: $<table_name.col_name> or $<.col_name>
reference a range: $<table_name.col_name:row_name> or $<.col_name:row_name>
total a column excluding the Header & Totals row: (-sum col_name -Header,-Totals-)
Could you please point me in the right direction. Thanks for all your help. DannyB 2011-10-18 9:33 AM
Have you looked at SortableTables? It is javascript based and has a SUM feature. Anyway, this is not the place to discuss this, and I cannot help you with it. Perhaps bring your queastions to the PmWiki Users email list? - HansB October 19, 2011, at 02:31 AM
I'll check elsewhere and if you want to delete this section that's fine with me. I don't know the proper protocol.
Just an FYI...I found a solution to my parent page creating a child page and passing information to it. I used the httpvariables recipe like so:
[[Forms.DistributionNew?Proj_ID={$:Proj_ID} | HERE ]]
That passed the Proj_ID value so I could link back to the parent page and collect whatever information I needed. Including all the sections into one form would have taken a long time as each section created long pagelists for select fields. Thanks again for the help as it has kept me moving ahead after a very long time of running into major road blocks. It feels like Friday! DannyB 2011-10-20 5:41 PM
On a similar page-ID/Name-creation note: I want to create a target pagename using the value from an input field. Can I do that with markup similar to this?
(:fox NewCustomerForm target={(pagename "Customers.{$$Cust_ID}")} redirect=1 ptvclear=1 template=FoxTemplates.CustomerNew:)
(:input submit post value="Create New Customer":)
!!Customer Information
||
||! ID||(:input text name=Cust_ID:) ||(ex. SmithDaniel)||
...
The following type of form works, but in the previous example I don't want the target auto-generated.
(:fox NewDistributionForm target="Distributions.{$:New_Distr_ID}" redirect=1 template=FoxTemplates.DistributionNew:)
(:input submit post value="Create New Distribution":)
!!Distribution Information
(:New_Distr_ID: DST{(serial Distributions DST)}:)
...
Try in example 1 changing the target to
target="{$$(pagename Customers.{$$Cust_ID})}"
The markup expression {(pagename ....)} gets evaluated when the form loads, while in this syntax: {$$(pagename ....)} it gets evaluated after the form is submitted, early on in Fox's processing, evaluating replacement variables. -HansB
That makes it work! Thanks again. You saved the day. - DannyB 2011-10-14 3:18 PM
Pursuit: Create a child page in a new window while creating a parent page. Or create a parent page with a link/button that would create a link, related child page.
I am trying to use pagetext variable values from one form while creating a new form in a new window.
As I am creating a new project page with Proj_ID containing an ID string, I would like to pass the value of Proj_ID to a child fox template page. I need the ID passed so that the other page links back to the parent page. Currently I have to copy the new project ID and paste it into the child page. Here is the markup I'm using in the new project and Forms.DistributionNew is a fox form page. New projects are pages in a Projects group with distribution entries in a Distribution group.
%newwin% Click [[Forms.DistributionNew | HERE ]] for a new distribution entry in a new window or tab.
!!!Active list
(:pagelist group=Distributions link={$FullName} fmt=#projectdistrtable:)
I don't think I understand the problem. A Fox form allows creation of several pages at once, each created via its own template page, with several markup lines like (:foxadd TemplatePage=>TargetPage ... :) or (:foxadd template=TemplatePage target=TargetPage ... :). - HansB October 06, 2011, at 03:00 AM
Thanks for your response. I'm too used to a regular programming procedural orientation where data is passed to the next "step" rather than collected all at once and written to other pages. I'll rethink my form/multi-child-page creation procedure. - DannyB 2011-10-07 10:00 AM
If you want to use a two step process, you could have Proj_ID written as value of a PTV on the first page, then use that variable in the form or the template used which creates the second page. - HansB October 07, 2011, at 02:05 AM
Thanks for the suggestion. I do have the Proj_ID stored as a PTV on the first page. I still don't understand how the second page form knows about the first pagename to get the Proj_ID from it? Or are you saying I have the first form create the second page and store the Proj_ID in it? But I don't always need the second page. - DannyB 2011-10-10 10:56 AM
Could you include the form which creates a Distributions page into the Project page, instead of a link to the form? Then the form can use the Proj_ID PTV directly. If you wish, you could hide the form using the Toggle recipe, so the Create new distribution link will just show the form. The included form needs to be part of the Project template, and any variables in it may need protection from being evaluated when the New Project form gets submitted, by using a triple $$$ syntax (see Fox#template). Or use (:include Forms.DistributionNew:) as part of your ProjectNew template page. - HansB October 10, 2011, at 08:07 AM
That is what I had in the beginning and may go back to it using the new ideas you have given. I'm just getting a better feel for how this single form distributing to multiple pages works. The next challenge is updating the data in a similar one page form format. Thanks again.
DannyB 2011-10-11 02:24 PM
I need to add that it would be better to use (:foxsource Forms.DistributionNew:)instead of (:include Forms.DistributionNew:). See under Fox#markup. - HansB October 11, 2011, at 03:33 AM
I thought about that. Did you mean (:foxform Forms.DistributionNew:). I'm assuming that markup needs to be inside a fox begin/end section. I'll change it to that as that fixed my problems before. I wish there was something like (:foxsource Forms.DistributionNew:) that I could just type right in outside of a fox form - DannyB 2011-10-14 3:31 PM
sorry, yes, I meant (:foxform Forms.DistributionNew:). This markup will simply render as a fox form as given in parameter (page plus optional page section of form location). It does not need to be enclosed with #foxbegin# and #foxend# markers. Those are useful only when using a foxdelete link or button action on a section marked by these markers supplied via the template. (:foxform <source> :) works like (:include <source>:), but without dropping any replacement variables, which may be present in a fox form. So it is a safe way of including a fox form from another page. Especially it will include forms present on page Site.FoxForms in an anchored section, when specifying the anchor as parameter for <source>, similar to using templates in the fmt parameter of the pagelist markup, and other PmWiki markup directives using templates. It is for use outside a fox form. It does not need to be part of a template either. it is just a special safe (:include ..:). What does (:foxform <source> :) not do for your purpose? -HansB
That's what I'm doing now. I was under the misconception that the foxform markup only worked inside (:fox ...:) markup. I'm still looking for a relatively simple way to call javascript checks & lookups while entering a form (ajax stuff). This is a whole different topic. I'm also considering writing a plugin to turn tables into simple spreadsheets. Even just a basic total up rows or columns, basic math between cells and only computing left-to-right and top-to-bottom. Pmwiki is great and thanks for your forms plugin! DannyB 2011-10-17 8:35 AM
"ptv" should be listed as one of the options for the actions available in $FoxPagePermissions. Your docs are quoted below.
$FoxPagePermissions['namepattern'] = "actionname,actionname,..";. Action names are add, replace, copy, newedit, delete, mail, all, none. all meaning all Fox actions are allowed, none meaning no Fox actions are allowed. See examples in box below.
Otherwise, you have to set permissions to all to get ptv updates to work. -MagicBeanDip
You're right. Thanks! Done. - HansB May 18, 2011, at 01:25 AM
keepinput not working with redirect=#anchor
Hi Hans, i'm wondering if this is appropriate action. in my foxform i have keepinput=1 set. if don't set redirect= to anything, then i am returned to the same page after submission, and all the form fields are still populated with data. that's great. but, if i want to redirect back to the form-section on the page (which is at bottom), by setting redirect=#formSection, the form fields appear empty when returned to the page. is this correct? and is it the same on your system? thanks, overtones99 April 19, 2011, at 07:41 PM
Yes, that is the expected behaviour. keepinput=1 works much the same like (:input defaults request=1:)(InputDefault). But any redirect= does what it says: a redirect to a new page (or in your case to the same page's anchor). All Input values are lost in the process. You could possibly use HttpVariables to get input values via GET by adding them to the redirect url string. But this is prone to problems due to disallowed characters like spaces etc. There are also security concerns to be contemplated with this method.
Another possibility may be to save the $InputValues array as a SESSION variable, and reuse it after the redirect.
Another possibility may be to use a modified version of RememberEditPosition, basically using javascript to remember the window scroll position. Try the code below:
Add to config:
$InputTags['win_scroll'][':html'] =
"<input type='hidden' name='win_scroll' id='win_scroll' value='".
intval(@$_POST['win_scroll'])."'/>";
$HTMLHeaderFmt[] = "<script type='text/javascript'>
function addEvent( obj, evt, fn ) {
if (obj.addEventListener) obj.addEventListener( evt, fn, false );
else if (obj.attachEvent) obj.attachEvent( 'on'+evt, fn );
}
var ws;
addEvent( window, 'load', function() {
ws = document.getElementById('win_scroll');
if ( ws.value > 0 ) {
document.body.scrollTop = ws.value;
window.pageYOffset = ws.value;
document.documentElement.scrollTop = ws.value;
}
addEvent( ws.form, 'submit', function() { ws.value = getScrollY(); } )
} );
function getScrollY() {
var scrOfY = 0;
if( typeof( window.pageYOffset ) == 'number' ) {
//Netscape compliant
scrOfY = window.pageYOffset;
} else if( document.body && document.body.scrollTop ) {
//DOM compliant
scrOfY = document.body.scrollTop;
} else if( document.documentElement && document.documentElement.scrollTop ) {
//IE6 standards compliant mode
scrOfY = document.documentElement.scrollTop;
}
return scrOfY;
}
</script>";
and add this new hidden field to your form, just below the (:fox <formname> ...:) markup:
(:input win_scroll:)
and don't use redirect=#anchor, but use keepinput=1 in your form. - HansB April 20, 2011, at 02:56 AM
Target not working when a FoxForm is included?
Hi Hans, i just discovered that if i place the following code directly on a page (say, MyPage), and then fill out the form, it works as expected... but then if i try to place it in a separate page (ex MyFoxForm), and then include it on MyPage via (:include Group.MyFoxForm:), then the target is not completed correctly. {$$newPageName} won't plug into the target and instea everything is posted to the current pagename. i also tried {*$$newPageName}, but to no avail. what am i missing? i created a foxfilter to see what was coming in via "fields", and newPageName contains a valid string but just isn't being passed to target.
>>frame padding=10px width=500px margin-left=300px<<
(:fox librarySubmission template=Templates.NewLibraryPage_Pamphlet target=Library.{$$newPageName} redirect=Library.index keepinput=1:)
(:input text name=newPageName size=50px:)
(:input hidden foxfilter testTask:)
(:input submit post Submit:)
(:foxend librarySubmission:)
>><<
thanks,
overtones99 April 07, 2011, at 03:12 AM
you got replacement variables in the form, and these get dropped when the form is included via (:include..:) markup. This did not used to be the case, but Include removes unset template variables since PmWiki version 2.2.14. See PagelistVariables#EnableUndefinedTemplateVars. You need to set in config.php:
$EnableUndefinedTemplateVars = 1;
The Fox page should have a prominent note about this, as the default include behaviour now wrecks any Fox form which contains template variables. With hindsight I perhaps should have used a different syntax in Fox for replacement variables used in a form than the variables use in templates. - In future I may add a custom markup to include a Fox form, loaded from a page or page section. - HansB April 08, 2011, at 03:13 AM
ahh. so glad i'm not going crazy. i spent awhile experimenting, and almost began to believe my setup was entirely off. this is unfortunate, tho, b/c i'm actually a fan of the new feature as it helps me write more concise conditionals in pagelist templates. anyways, at least i know that it will works if i place the form directly on the page rather than including. thanks for pointing this out. overtones99 April 08, 2011, at 03:49 AM
I am grateful you pointed this out! I have now added a new markup to fox.php: (:foxform <source>:), working similarly like a simplified (:include:) directive, but without dropping empty variables. I added a section Including a form from another page to Fox as well. - HansB April 08, 2011, at 08:09 AM
WOW! i can't believe you responded and wrote new code so quickly! that's amazing! i will try it out! thank you so much! : )
overtones99 April 09, 2011, at 02:45 PM
Changing line color with foxcheck
Hi Hans
i'm creating a questionnaire, and all of the questions are required, so i'm using foxcheck. if someone fails to answer a question, i'd like for the entire question to turn red and bold, rather than sticking an asterisk right next to it. to do this, i tried:
(:foxcheck name=Q1,Q2,Q3 msg='%red%':)
but this doesn't work. to further test this, i tried the following to see what would be output:
(:foxcheck name=Q1,Q2,Q3 msg='%red%ZZ':)
with a line like (:foxmessage myForm Q1:)2. Blah blah blah?, these produce the following markup:
<span style='color: red;'>ZZ</span>2. Blah blah blah
... and hence the line remains it's normal color.
i've also trying changing msg to msg='%apply=block red%' and various other combinations without success.
any suggestions?
thanks,
overtones99 March 28, 2011, at 06:04 AM
Try using a wiki style on (:foxmessage:), like
%red%(:foxmessage myForm Q1:), instead of in the msg text inside the foxcheck markup. (:foxmessage:) always delivers unstyled text, and you can style it by styling the markup, or make it bold by enclosing it in ''', etc, exactly like inline text. - HansB March 28, 2011, at 08:42 AM
Hi Hans. i think the point is being missed. in this example (:foxmessage myForm Q1:)2. Blah blah blah? i want the question 2. Blah blah blah? to be it's normal color when filling out the form, and then the entire line should turn red if it's not completed. putting a wikistyle like %red% before the foxmessage (as in %red%(:foxmessage myForm Q1:)2. Blah blah blah?) won't work in this situation, as the line will always be red. the new style should only appear when foxcheck is triggered. is this possible?
thanks!
overtones99 March 28, 2011, at 08:56 AM
So you want to use foxcheck in a way it was not designed! OK, try this:
(:foxcheck name=Q1,Q2,Q3 msg='%spanafter hidden% ':)
(:foxmessage myForm Q1:)%dummy%2. Blah blah blah?%%
and add to pub/local.css:
span.spanafter + span { color:red; font-weight:bold; }
.hidden { display:none; }
So when foxcheck gets triggered, it will add as foxmessage a span around a non-breaking space (we need some content, but we hide it with the "hidden" class!) with a class "spanafter". The text after foxmessage will be in a span class "dummy". The css rule will style the text in the span following our span class "spanafter", i.e. the dummy span, in color red. A bit of a trick shot, all this! - HansB March 28, 2011, at 09:52 AM
To avoid all this I have now updated fox.php with an extended (:if foxerror <formname> <fieldname>:) conditional, which you could use to add a wiki style for instance, or a text message, directly inside the if ... endif container, instead of foxmessage and the error msg in foxcheck markup. Note that it still needs foxcheck markup to define which fields should be checked, or in what manner. See also Fox#foxcheck - HansB
ahhhh. (:if foxerror...:) works great! thanks so much for the quick and easy fix! overtones99 March 29, 2011, at 08:42 AM
I'm using the Shoutbox, not sure to put my question here or there. It might be a more generic question though... Anyway, hope you can anser it.
I'd like to show the shoutbox to everyboy, but only show the text field (where you can post something) if the user has the $Author set. If he doesn't have the $Author set, a textbox should appear asking for it, thus setting $author when he hits submit.
I do know how to use conditional markup, but not how to set the $Author.
(:if {$Author} "":)
# I guess something like this:
(:input text class=?? size=15:)
# But how to set the $Author variable?
(:else:)
(:input textarea class=shoutbox shout cols=20 rows=2:)
(:input submit post Enter:)
(:if:)
Miels? February 25, 2011, at 09:38 AM
HansB: it does not make sense to me to hide the textarea box, because the purpose of the shoutbox is to post comments, and not to log on or set up an author name. But you could show an author input box conditionally like this:
(:if equal {$Author} "":)
Name:(:input text author value="{$Author}" size=8:)
(:else:)
(:input hidden author value="{$Author}" :)
(:ifend:)
Now that's a quick reply! Thanks! :D
Regarding this: it does not make sense to me to hide the textarea box, because the purpose of the shoutbox is to post comments, and not to log on or set up an author name.
When you post something to the shoutbox when $Author hasn't been set yet, the shouter's name appears as "Profile?". Since it's relevant to know who is shouting, one should first set their name. Only then they should be able to post something on the shoutbox.
If a visitor would like to set his/her name without such a text field, he should first edit a page, enter their name below the text area, and hit preview. Only then the $author gets set.
Miels? February 26, 2011, at 05:18 PM
HansB: Well, then have the author field shown, if author is unknown, and hidden, if known, as in the snippet I provided. And add an input check for the author field, so it becomes impossible to post without entering a name. You need to add a (:foxmessages:) directive as well, if you use the server-side method. Not needed if you use the javascript method (adding formcheck=author to the fox form.... markup. See Fox#foxcheck
Great, that helps a lot. One final question (I hope ;)): When using your snippet, the name the user fills out isn't remembered. When posting another line to the shoutbox (or editing a page) the Author field is empty again. What I was actually looking for was a way to mimic the Author text field that is on a regular edit-page (though I think it can be hidden once the author has been set) Snippet above does this
Miels? February 26, 2011, at 05:36 PM
Is there a way to make the page creating code work with Hierarchical Groups? I can create pages at the group level (grp/page) but cant any lower (grp-page.sub).
This code redirect to the correct page but does not create it.
(:foxmessages:)
(:fox newpagefrm1 template=Site.NewPageTemplate redirect=1:)
(:input hidden target 'TestReports-Sites.{$$projectname}':)
(:label projectname "Enter the Name of the Project: " :)
(:input text projectname size=20 id=projectname:)(:input submit post "Create Page":)
(:foxend newpagefrm1:)
Thank you. (Note that I am using |Form Extensions in that code as well.
Guy Moreau Dec 8,2010 10:56 EDT
Works fine with me, but I did not use FormExtensions. Entering project name "test" created page "Test" in group "TestReports-Sites". Take out the redirect for testing to see error messages. Perhasp you are not allowed to post to that group, and need to add permissions? - HansB December 08, 2010, at 10:16 AM
Ah yes, it is a permissions thing. Silly me. Thank you. Guy Moreau
Hi Hans. Is it possible to update the same PTV on multiple pages, but with different values for each page? For example, let's say I have two pages, "Red" and "Blue". Each has the PTV (:score:0:). I want to create a form that let's me update both PTVs at the same time, but with different values for each page (e.g. (:score:15:) on the page Red, and (:score:20:) on the page Blue). I've tried things like:
(:foxptv Red ptvfields=score foxtemplate=15:)
(:foxptv Blue ptvfields=score foxtemplate=17:)
but that doesn't seem to work. I realize I can add (:input hidden score 15:) to the form, but that would change (:score:0:) to 15 for both pages... any way to do this? --James November 12, 2010
Fox cannot update PTVs of the same name with different values for different target pages. There is no provision to remap PTV names, Fox will always update the PTV of the same name as the field name. You need to use different field names to pass different values to PTVs with the same field name. Instead of using foxptv you could try foxreplace to do a text replace on the target page, and thereby changing the PTV value. - HansB November 13, 2010, at 04:59 AM
Hello Hans. Two PITS entries are related to Fox 01183 & 01185 - not sure if they are still active, if you have a minute you may want to check them out. --Petko November 11, 2010, at 05:10 PM
Done, entries closed. Thanks for the pointer! I don't usually check PITS entries and rely on Fox related queries being posted here or the relevant Fox application Talk page. HansB November 12, 2010, at 02:26 AM
Hello. I'm trying to figure out if there's a way to completely hide hidden inputs so they are not viewable in the page's source. For example, with a form like...
(:fox myform ptvtarget=SomePage:)
(:input hidden answer Yes:)
(:input submit post Go:)
(:foxend myform:)
...the user can just copy the html source to their desktop, edit it so that "Yes" is "No", then submit it. I can't figure out a way around it. Maybe some way to process fields that are stored on another page? Or something? Any ideas would be greatly appreciated. Thanks! James October 17, 2010, at 12:51 AM
Hans: you could use a fox filter function, and have your value supplied through it. Fox filter functions are processed after the form submission and before any other Fox processing of the submission.
See Fox#filters
Remove the (:input hidden answer Yes:) and add to the fox form something like:
(:input hidden foxfilter mycustomfilter:)
then put in config.php, before fox.php is included, something like:
$FoxFilterFunctions['mycustomfilter'] = 'MyCustomFilter';
function MyCustomFilter($pagename, $fx) {
//my custom processes here:
$fx['answer'] = 'Yes';
return $fx;
}
Do arrays work?
Bergwitz March 01, 2010, at 01:04 PM I can't get arrays to work. I tried to use checkboxes to sets some categories to the page like this (:input checkbox tag[] "[[!Category1]]":), and repeated for Category2, Category3, etc. I placed {$$tag[]} in the template. This was extremely buggy. If I didn't check any of them, nothing would be posted to the new page, and if I checked one or more of them the content from the form would be posted twice. At no point did I get it to post more than one value to the page.
This is not a bug, but a feature! If you use an input array as you do with checkboxes named tag[], Fox will convert this into a comma separated list of values submitted, accessed via markup {$$tag} in the template. If one uses markup {$$tag[]} in the template template, then this will not be substituted by a list of values, but instead Fox will repeat posting of the template, each time with another array value, starting from zero. One can break the template into sections with {[foxsection]} markers, and each section will be treated separately. That way one can avoid that Fox will write undesired duplications, and only writes repeats of array values with desired duplications. I should really add a section about this into the main documentation. right now it is documented only as comment notes to the FoxTemplateEngine function in fox.php. And I think the note about use of {$$field[num]} in the template is incorrect and the behaviour buggy in this case. - HansB March 03, 2010, at 01:06 PM
Accented characters in FoxNotify templates
SteP February 14, 2010: I noticed that an accented character, such as é, in a FoxNotify email template turns into funny (UTF8) characters when gmail displays the email message. $EnableFoxNotifyHTMLEmail = false (default).
Writing error messages from a foxfilter function
SteP February 4, 2010: A foxfilter function can validate input and write an error message:
if( $field['Name1'] == 'invalid' ) FoxAbort($pagename, 'please re-enter field Name1');
The message shows up wherever in the page you place markup (:foxmessage formname list=nocheck:).
- Omit
list=nocheck to merge messages from your foxfilter function and from markup (:foxcheck Name2 msg='Name2 invalid':).
- You may not want to merge error messages if markup
(:foxmessage formname Name2:) appears elsewhere in the page. Such markup is useful to show Name2's message by the form input field. Merging messages will show the message for Name2 twice.
To validate multiple fields and show a single message use:
This will show a block of error message lines when markup (:foxmessage formname:) is used.
- However, if
(:foxmessage formname list=nocheck:) is used, then Fox will cram all messages onto a single line.
- You can patch fox.php to separate out multiple error lines. Modify the top part of function FoxDisplayMarkup
function FoxDisplayMarkup($pagename, $mode, $args) {
global $FoxMsgFmt, $FoxDisplayFmt;
if (!$FoxMsgFmt && !$FoxDisplayFmt) return '';
$opt = ParseArgs($args);
$opt[''] = (array)@$opt[''];
$form = isset($opt['form']) ? $opt['form'] : array_shift($opt['']);
$name = isset($opt['name']) ? $opt['name'] : array_shift($opt['']);
$msg = '';
if($FoxMsgFmt) {
+++>> if (!$form && !$name) $msg = implode("\\\\\n", array_flip(array_flip($FoxMsgFmt))); //show all messages
elseif ($form==@$_REQUEST['foxname']) {
if (isset($name) ) $msg = @$FoxMsgFmt[$name]; //show error message from check 'name'
elseif (@$opt['list']=='nocheck') //show non-name messages
***>> $msg=implode("\\\\\n",array_flip(array_filter(array_flip($FoxMsgFmt), 'is_int')));
elseif (@$opt['list']=='check') //show name messages
***>> $msg=implode("\\\\\n",array_flip(array_filter(array_flip($FoxMsgFmt), create_function('$x','return !is_int($x);'))));
+++>> else $msg = implode("\\\\\n", array_flip(array_flip($FoxMsgFmt))); //show all messages
}
}
- A by-product of this patch is that only the first line of a set of identical lines will be shown.
SteP, do you propose your patch could be integrated into the next fox.php upgrade? Any isues with this? HansB February 04, 2010, at 11:50 AM
- Hans, I do propose so. I'm not seeing any issues with it. It affects output in two ways: lines are kept separated - as they should be; multiple identical messages are reduced to one message. Perhaps someone could object to the second point, but I don't. SteP February 05, 2010.
- Hans, I extended the use of array_flip to all instances of $FoxMsgFmt. This ensures that all identical messages aren't repeated. It's a matter of taste, I do prefer it this way. The original patch is marked with
***>>. The extended patch is marked with +++>>. SteP February 07, 2010.
Localization strings
SteP January 07, 2010, at 03:13 PMHere's a list of localization strings collected from fox.php 2009-05-15. The one string that I marked (*) looks like it should be included in this list, although I didn't find it within $[] in the php code.
Please enter valid input!
Error: input not permitted
Error: no target specified!
Error: no target specified or target not found!
Error: Target list is not in the group for FoxNotifyList(*)
Successful post to
Error: could not find target section on
Nothing posted to
Error: Template page
is missing!
Error: Template is missing!
Error: Found no mark to add above!
Error: Found no mark to add below!
Error: Found no form to add above!
Error: Found no form to add below!
Error: Found no mark to insert after!
Error: Found no mark to insert before!
Error:
is not a valid option with 'add'!
Error: No string to find!
Error: could not find endmark!
is not a valid option with 'replace'!
Error: max iterations exceeded while replacing variables!
Error: cannot recognise PTV format
Error: Missing or wrong Access Code!
Error: Missing or wrong Captcha Code!
Error: You are not allowed to post to this page!
Page
exists already. Please choose another page name!
Error: No text or missing post!
Error: processing stopped before maximum script timeout.
Page process:
Invalid parameter:
Input condition failed
Formname valid characters
SteP January 07, 2010, at 11:18 AM: I'm using (:fox {=$Name} ...:) in a pagelist template, so the name of the current page is used as unique formname. The issue is that fox markup breaks on pages names that include hyphens because the markup regex matches \w only. Would it be safe to change the regex from/to
/\(:fox ([\\w]+)\\s?(.*?):\)/
/\(:fox ([-\\w]+)\\s?(.*?):\)/
(and (:foxend :) too)? Or do you think something's going to break? I realize that formname parsing occurs in other fox markup too, but all I need is fox and foxend, so I guess I'm looking for a quick fix. Or is there another, smarter way to generate unique form names inside a pagelist?
Adding Text not working with put={$$radiobutton}
I'm trying to modify the example from FoxTextReplace to simply add text to either the bottom or the top of the page (in this case Test.Test). Everything is fine if I simply hardcode put=top or put=bottom, but if I try to use a radio button to toggle btwn top/bottom, i get the following error msg:
Error: '{$$putadd}' is not a valid option with 'add'!
Nothing posted to Test.Test
Here is the code I'm using:
>>lframe width=55pct bgcolor=#ffeeee padding=10px<<
'''Add Text to Pages'''
(:fox addtext put={$$putadd} target='{$$(plist {$$pat})}' foxtemplate="{$$new}":)
||
|| Add text to the:||(:input default putadd top:)(:input radio putadd top:) top (:input radio putadd bottom:) bottom ||
|| Add text string:||(:input text new size=40:) ||
|| To Target Pages:||(:input text pat size=40:) ||
|| ||(:input submit post 'Add Text Now':) ||
(:foxend addtext:)
>><<
[[<<]]
Using a toggle this way seemed to work fine in my own TextReplace recipe. what's wrong here?
thanks, overtones99 December 23, 2009, at 06:51 AM
'put' is one of a list of special field names which will not undergo a variable replacement. The list is in a variable $FoxFxSafeKeys (check fox.php for it), and you could set this variable before loading fox.php and exclude 'put' from it. Then the radiobuttons should work. - HansB December 24, 2009, at 06:53 AM
hi. i guess what i'm confused with is that my example here works completely fine with radiobuttons toggling the 'put' value... is there a difference in the "flexibility" of the 'put' field between foxaction=replace and foxaction=add? overtones99 December 25, 2009, at 03:11 AM
In this second example you use field name 'put' in the radio buttons, thereby setting the 'put=' parameter directly and avoiding a variable replacement. The first put={$$put} is not needed in that example. - so you could use 'put' as radio field name in the first example, instead of 'putadd', saving you the hassle of having to permit variable replacement on the 'put' parameter . - HansB December 26, 2009, at 08:19 AM
oooo, it works! thanks! didn't realize 'put' was synced up with the form inputs. great. overtones99 December 26, 2009, at 06:01 PM
FoxAbort - redirect to anchor?
Hi Hans. i'm currently using foxfilter to make sure a user's PTV input is in the correct form, or else it calls FoxAbort and explains the error. my question: is there a way to have the FoxAbort redirect to an anchor? i tried FoxAbort("$pagename#myAnchor", $msg), but that fails. without the anchor all works fine, except that the user is returned to the top of the page instead of the bottom where the form and error message are located.
(ps - after over a year of off-and-on fiddling with fox, i have to say i think it finally just clicked. forms and ptv replacement seem like such a cinch all of a sudden. thanks!!)
overtones99 July 30, 2009, at 06:31 AM
FoxAbort calls HandleDispatch($pagename, 'browse'), basically returning the user to view the page, and passing on any messages. There is no provision in HandleDispatch to direct to an anchor. In your filter function instead of calling FoxAbort you could call Redirect($pagename, $urlfmt), but this will not pass any messages on. $urlfmt needs to be a full http://..... string, and can have an anchor. So i see no real solution, but i will think about this a bit more. - Could you not use Fox's input validation features (with (:foxcheck...:) markup)? You can use replaceemtn variables inside these to validate input, and have corresponding error messages generated and displayed beside the input fields. - HansB
Ah. Thanks. i guess then a possible solution (on my end) is to use the Redirect you mentioned, and supply an error msg switch via the urlformat: Group.Name?error=fieldCheck1#anchor -- and then have some markup in the page a la (:if equal {$?error} "fieldCheck1":)%red%wrong format for x%%(:ifend:). i think i've actually done something similar before, but was afraid that FoxAbort and HandleDispatch might be doing some important internal things...
oh, and yes, in the meantime i actually did discover the (:foxcheck name regex=...:) option and have implemented it - it works great - though the anchor situation is still the same with that.
Thanks! overtones99 July 30, 2009, at 05:20 PM
Fox Page Management - again
Is it possible - in one foxform - to create both a new page with ptv's saved to this created page and at the same time save ptvs to another already existing page?
What I have in mind is something like
(:fox form target={$Name} ..... :)
... form inputs ....
(:input hidden target '{$$(serialname Europe {$$processpage})}':)
(:imput submit post "Enter":)
With the above I want to write most ptvs to a newly created serialnumbered page, but have some ptvs also saved to the current page.
I'm not sure how to compose the syntax for this. As written as above it doesn't work. Thanks
use several markups of type (:foxptv TargetPage ptvfields=.. ptvfmt=.. ptvclear=.. :) each with different target page specified. You need also to set ptvfields= for each target accordingly. ptvfmt= and ptvclear= is optional. - HansB July 17, 2009, at 08:33 AM
Fox Page Management
Using
(:messages:)
(:fox newtodo template=Template redirect=1:)
(:input hidden target '{$$(serialname Europe Test- )}':)
(:input submit post "Create New ToDo Page":)
(:foxend newtodo:)
Produces a new page Test-xxx where xxx is an incremental number with the template text included.
However if I try this:
(:messages:)
(:fox newtodo template=Template redirect=1:)
(:input hidden Test:)
(:input hidden target '{$$(serialname Europe {$$Test-})}':)
(:input submit post "Create New ToDo Page":)
(:foxend newtodo:)
I get the same page (it has number 001 but does not increment) but with the template text added below the last submission.
I can figure what I am doing wrong - any clues?
Thank you
Seems to me that {$$Test-} does not exist, {$$Test}- may be bette rto pick up the value from field named 'Test'. But the field (:input hidden Test:) has no value set, so what shall {$$Test} be? - HansB July 10, 2009, at 10:06 AM
Indeed {$$Test}-.... Ithink it's a case of "Friday afternoon ...." I need more coffee! Thanks for the quick response.
Suggestions for more powerful custom filters:
1. Allow separate filters for data coming into the form versus data going out. This would allow things like inserting formatting markup in a PTV that exists on the page, but that the user doesn't see on the form.
I'm not sure what you mean by 'data coming into the form vs data going out'. If form fields pick up PTV values they get picked up when the page loads. Fox has no means to change these at page loading time. Fox can only change values when the form is submitted. A filter function can be used for that. HansB
2. Allow different filters for different form fields. For example, the form could have a text box in which the user is asked to enter categories as plain text separated by commas. A MakeLink filter would add the markup as the data is saved to the page. In the same form, however, a phone number text box would have different filters applied.
You can do that already. You can specify more than one filter, each function acting perhaps on one form field value submitted. Or you can write one filter function which manipulates different form field values. HansB
- RandyB
Combining Fox and Foxnotify
Not sure if this best fits Fox or Foxnotify comments - please feel free to move if inappropriate.
I am trying to combine a Fox form involving PTV's that get written to a page.
The idea is that when the submitter clicks "Enter" the ptv's are written to the page and at the same
time the e-mail is sent to the users recommending they view the updated page.
I have this in my form:
(:fox ITOutageApprovalform template=MgmtOps.ITOutageApprovalFormTemplate
target={$Name} ptvtarget={$FullName} ptvfields=number redirect=1
put=above mark=[[#table]] :)
(:foxmail template=FoxNotifyLists.FoxNotifyTemplateITOutage
target=FoxNotifyLists/ListITOutage:)
The issue I have is that using this syntax I get three emails for each form submission, the first one is "correct" the other two the ptv's are garbled.
However the target page is updated correctly.
Yet if I use this syntax:
(:fox ITOutageApprovalform :)
(:foxptv template=MgmtOps.ITOutageApprovalFormTemplate target={$Name}
ptvtarget={$FullName} ptvfields=number redirect=1 put=above
mark=[[#table]] :)
(:foxmail template=FoxNotifyLists.FoxNotifyTemplateITOutage
target=FoxNotifyLists/ListITOutage:)
I receive one e-mail correctly - but the target page is not updated with any of the PTV's.
Can you point me to the best way to achieve this?
Thank you
The syntax for (:foxptv ...:) markup is a bit different, like
(:foxptv TargetPage ptvfields=.. ptvfmt=.. ptvclear=.. :)
No template and ptvtarget (the target is the ptv target, only PTVs get dealt with there. If you need to add other content on the PTV target page, use a (:foxadd ...:) markup as well. - HansB
FoxAuth AND FoxPagePermissions?
Sorry if that's a silly question, but just for clarification: $FoxAuth alone doesn't do anything, right? If I set FoxAuth to read, I'm still not allowed to post, read permission or not. Only if I also add a FoxPagePermissions for the page to be posted to, I'll be allowed to post. Is this correct, or should FoxAuth be sufficient (I'm talking about regular page groups, not Site/SiteAdmin/PmWiki).
Thanks in advance! Clemens
You are correct. $FoxAuth is not sufficient. $FoxPagePermissions need to be set to enable the desired Fox action on the target page(s). - HansB
Ptvtargets
Thanks for debugging the form - too many statuses - oops!
And double oops as I forgot to set the target group in Foxconfig.... hence why it wouldn' post. argh...!
I'm trying to post a PTV to two pages using some very basic markup
(:fox D4RampUp ptvtarget={$FullName},D4RampUp/Status redirect=1:)
[+Summary Status:+](:input radio $:APACStatus "Red":) Red(:input radio $:APACStatus "Yellow":) Yellow
(:input radio $:APACStatus "Green":) Green (:input radio $:APACStatusStatus "White":) None
(:input submit post "Submit":)
(:foxend D4RampUp:)
What i find happening is that the ptv is updated for the first page - the form page, but the second page "D4RampUp/Status" is not updated - nothing seems to be written to the page. I think i am misunderstanding how the ptv targets are working. Can you advise. Thanks Graham
your form works for me, apart from the $:APACStatusStatus, which is one Status too many! Fox updates PTVs on all ptvtarget pages. Since you use a PTV syntax for the field name, fox will create the PTV if it does not exists. Normally Fox would update any PTV on any ptvtarget page for which there is a corresponding field name (like input name abc corresponding to a PTv 'abc'). If ptvfields is specified only those named PTVs will be added or updated on ptvtarget pages. By default Fox adds a new PTV as a hidden PTV. - You can also use several (:foxptv ....:) markups, to target different pages with different PTVs for updating/adding. - hope this helps! - HansB
Using $FoxPagePermissions
I was trying to get a simple blog working, using something like FoxCommentBox to post to pages in a "Comments" group. For a "blog page" I included the appropriate comment page and FoxCommentBox. I tried to set $FoxPagePermissions['Comments.*'] = 'all';, but nothing was ever added to the target page. It wasn't until I set $FoxPagePermissions['*.*'] = 'all'; that comments started working. Is it correct that $FoxPagePermissions is being used to check the page including the fox form, rather than the target page? Or could something else be amiss? If my supposition is correct, is there a setting that will be for the target page, rather than the page including the fox form?
No, page permission is checked for each target page, not the form page, if they are different. Make sure $FoxPagePermissions is set before including fox.php. - HansB
Disabling default posting success and failure messages
I found I needed/wanted to set ptvtarget={$Name} to put the ptv on the same page as the foxform.
One follow up point from doing this:
I have foxsuccess set to a "thank you" note on successful form submission.
However I now get the "Thank you" note followed immediately by "Successful post to pagename".
How can I turn OFF the successful post to page message yet still keep the "Thank you" note? May page reads as follows - with line breaks added
(:fox TCAPrimaryRequest foxcheckmsg="The form has not been completed correctly. It has NOT been sent.
Please correct the form where higlighted in RED and re-Submit."
keepinput=RequestorName,sunid,RequestorEmail,phone,LineofBiz,gem ptvfields=postcounter ptvtarget={$Name}:)
%blue%(:foxmessage TCAPrimaryRequest list=nocheck :)
(:foxmail template=FoxNotifyLists/FoxNotifyTemplatesTCAOtherTest
foxsuccess="Thank You - Your request has been sent." target=FoxNotifyLists/ListTCAOtherTest:)
I think if you put the foxsuccess= parameter out of the foxmail markup and into the fox markup it may do the trick! Otherwose try adding to config.php before inclusion of fox.php: $EnableFoxDefaultMsg = false; - HansB January 28, 2009, at 05:13 AM
FoxPostCount and setting up a counter PTV
Can you explain a little more how {$FoxPostCount} works.
I am using Fox form with Foxnotify to e-mail the form contents. I would like to count the number of times the form is used.
I can't get to increment and would like to understand more what I need to do.
Thanks
is a page variable which will give you the number of "#foxbegin" strings in the page. Usually that corresponds to the number of message posts, with the message being enclosed with #foxbegin# and #foxend# markup in the template. This is needed for foxdelete to delete an entire section thus marked. And useful for counting!
But without the #foxbegin# marker in a posting template it will be useless. you may be better to add a custom PageTextVariable to the page, and have it incremented on each form submission. Try this:
- Add a PTV with initial value 0:
(:SubmitCount: 0:)
- Show the value anywhere with
{$:SubmitCount}
- Add to your form
(:input hidden SubmitCount {$$(inc {$:SubmitCount})}:)
- Perhaps add to your fox markup ptvfields=SubmitCount, or add SubmitCount to the list of names for ptvfields (names seperated by comma).
- Add the (inc value) markup expression definition to config.php
$MarkupExpr['inc'] = 'MxInc($args[0])';
function MxInc ($arg) {
if(!is_numeric($arg)) return $arg;
return $arg + 1;
}
HansB January 27, 2009, at 05:10 AM
FoxNotify and foxxsuccess message
Hi there--
I am using FoxNotify to create a form that sends a response via e-mail. For some reason, foxsuccess doesn't appear to work--I've used it in the (:fox:) line as you described in FoxNotify as in the following:
(:fox wrform foxsuccess='Request sent successfully!':)
and instead I get the message like this:
Successful post sent to {$PageName} (as in the default)
Am I misunderstanding something?
Thanks,
Jon
Try adding the foxsuccess parameter to the (:foxmail ...:) markup instead of the (:fox ... markup:). I think it only works with the fox markup if there is a target parameter specified within this markup. I will amend the foxnotify example, an dlook into this whole issue of allocating foxsuccess and foxfailure messages. - HansB November 26, 2008, at 10:49 AM
I updated fox.php and improved the foxsuccess etc handling (I hope). It should now work also with your orginal form (foxsuccess parameter in fox markup) - HansB November 26, 2008, at 12:04 PM
Thanks Hans--that does work nicely. JonHaupt
FoxPagePermissions for several groups
As always, thanks for your quick fixes. I'm probably asking a very simplistic question. As of now, this is what is in my config file for fox security:
$group = PageVar($pagename, '$Group');
if ($group=='Main')
if ($group=='Custom')
{
$FoxAuth = 'read';
$FoxPagePermissions['Main.*'] = 'add';
$FoxPagePermissions['Custom.*'] = 'add';
}
#allow all foxactions on all pages for admin
#(Site and SiteAdmin groups remain excluded)
if (CondAuth($pagename,'admin')) {
$EnableFoxUrlInput = 'true';
$FoxPagePermissions['*.*'] = 'all';
}
include_once("$FarmD/cookbook/fox/fox.php");
Basically, the issue is that I would like to have more than one group that has Fox permissions. Normally I had the Main group and that worked fine. Now I need to add more groups (such as the Custom group), so I added them as above (which of course I'm not a programmer so you can see my lack of understanding...although I try). Now Fox doesn't work at all. How should I proceed?
Thanks, Real Chris November 03, 2008, at 04:33 AM
if ($group=='Main') if ($group=='Custom') is never true. Try instead:
if ($group=='Main' OR $group=='Custom') $FoxAuth = 'read';
$FoxPagePermissions['Main.*'] = 'add';
$FoxPagePermissions['Custom.*'] = 'add';
Ha! I tried that one before, although not like this if ($group=='Main' OR $group=='Custom'), anyway, that was perfect, it works now. Thanks, Chris Real Chris November 03, 2008, at 07:48 AM
Problem: foxcopy does not copy page attributes (fixed)
It appears that foxcopy does in fact not copy everything. If a template includes a title, then the title is not copied even if the markup exists. The reason is that 'title' is a key of its own in the template page together with time, diff, author etc. and it is incorrectly left out from the target (see PageFileFormat). The copied file does not work properly in pagelists sorting on title for instance. Could this be fixed in the next release? JHJ November 1, 2008 at 15:15 pm
Sorry to remind you, but could you please react to this issue. It seems to be a bug in the current fox.php. Pages that include a title markup (:title nnnn:), and are created by foxcopy, are not complete pmwiki-files and cannot be used in pagelists. Opening the created page for editing fixes the problem, but that cannot be the ultimate solution. foxadd does not have this problem. JHJ November 11, 2008 at 13:00.
Sorry, I have no fix for this yet. You are right, foxcopy ignores any page attributes including a title, and copies simply the template content unaltered, with no variable substitutions etc performed. So it is no real page copy, but a template copy. If your template contains a (:title :) markup, then this should be copied as well. - I am not sure yet how to change fox.php to do a proper page copy. - HansB November 11, 2008, at 06:06 AM
The problem is simply that the keyword 'title' is missing from the created file, even if it existed in the template-file. Template 'content' is indeed unaltered but the result is not in valid format for pmwiki. Keywords in pmwiki-files are generated by pmwiki so loading for editing and saving (without changes) will fix this type of problem in general. It may be enough to just save using an appropriate pmwiki-function? JHJ November 11, 2008 at 19:35.
I updated fox.php and hope this works now, with no bad side-effects. I added 'SaveAttributes' to the EditFunctions array used by foxcopy. Quite a simple change really. Sorry for being so slow on this! - HansB November 11, 2008, at 05:11 PM
TraceTrail link problem
I'm using a Cookbook file called Tracetrail http://www.pmwiki.org/wiki/Cookbook/TraceTrail (which you are familiar with since you authored tracetrail3.php and is the version I chose to use). I have installed that php file in my wiki which is currently running on the Triad skin. Also, I just recently installed Fox because I wanted to have some of its functionalities and the shoutbox possibility (http://www.pmwiki.org/wiki/Cookbook/FoxShoutboxAlternative). Anyway, somehow whenever I leave Fox commented in my config.php somehow Trace Trail instead of giving me the sites I've been to only gives me a "+" on my wikisite. Whenever I uncomment Fox, and leave Trace Trail commented, Trace Trail works again and I can see the names of the links I've been to. Is there a work around for this issue? I'm also using PMWiki pmwiki-2.2.0-beta65, which of course is fairly recent.
Real Chris October 20, 2008, at 11:58 AM
Edit: Forgot to mention that I have uncommented the security settings in Fox for the time being to see how I can fix this issue.
$TraceLinkFmt id set to '* [[{$PageName}|+]]'. try setting in config.php
$TraceLinkFmt = '* [[{$PageName}]]';
I do not see the connection with fox.php though. i thought the [[pagename|+]] markup syntax is generally defined in pmwiki, to show a page title rather than page name. HansB October 20, 2008, at 12:19 PM
Hans,
You're a genius! Yes, the markup $TraceLinkFmt = '* [[{$PageName}]]'; did the trick. Now both will display together.
I've been playing with this shoutbox markup, but the look of the shoutbox is pretty generic. I'm not sure if I want to keep it.
On a side note, I just used the example you gave:
# allow comment posting for all visitors in group 'Public'
$group = PageVar($pagename, '$Group');
if ($group=='Main') {
$FoxAuth = 'read';
$FoxPagePermissions['Public.*'] = 'add';
}
#allow all foxactions on all pages for admin
# (Site and SiteAdmin groups remain excluded)
if (CondAuth($pagename,'admin')) {
$EnableFoxUrlInput = 'true';
$FoxPagePermissions['*.*'] = 'all';
}
I did change the Main variable, but I still need to play with these security settings.
One thing I don't like from the shoutbox is that when I click on "Submit" it has to reload the wikipage, which is beside the point of having a shoutbox (should be done without having to keep resubmitting the wikipage). It seems to be more of a blog... ;-)
Thanks again!
Real Chris October 20, 2008, at 12:28 PM
Error: 'no target specified'
I am using the following foxform with no problem.
(:fox testform target=Eop.Test2 ptvtarget=Test2 template=#test :)
(:foxmessage:)
Just some text:(:input text $:text :)
(:input submit post "Submit":)
(:foxend testform:)
(:if false:)
[#test]
{$$text}
[#testend]
(:ifend:)
However using the same form and replacing line 1 with
(:fox testform target=Test2 ptvtarget=Test2 template=#test :)
or replacing line 1 with
(:fox testform target=Eop.Test2 ptvtarget=Eop.Test2 template=#test3 :)
both gives the following error: no target specified.
This might be the correct behaviour - I'm not sure - but it certainly took me a while to work out what was going on.!
I cannot reproduce this error. Do you use the latest fox.php? There was a correction in version 2008-09-10 to fix "no target" errors. - HansB September 25, 2008, at 04:56 AM
PS: the template parameter in your example is irrelevant (not used), nor is the target parameter, because you use (:input text $:text :) which aims at posting to a PTV.
Indeed upgrading to latest fox.php resolved this issue. I was using 2008-09-09. Sorry I should have spotted that earlier - my oversight.
Foxedit and Radio / Select Inputs
Thanks for the tip below - this works fine. I would like the user to only be able to select from a range of colours in the editform. However I am finding that when I use either a Radio or Select Input type in the foxedit form, even though the page displays the input types correctly before the editable ptv's are loaded, after they are loaded the form always replaces these input types with a text input. Writing Red/Yellow/Green etc creates the correct behaviour so the form is working correctly, but I want to control what can be entered for this ptv. Can this be done?
Are you saying that when editing using a custom foxedit form the form shows a text fields, even though you have radio input buttons in this form? Then please check your custom foxedit form and make sure it gets called with the foxedit link. - HansB September 23, 2008, at 03:51 AM
Yes - And this is where my error was. Thanks for pointing me toward it. Graham?
Changing a Cell Background Colour, using Fox and Foxedit.
Using Fox I can set a cell background colour, ie..
Form:
Red: (:input radio status "Red":)
Yellow: (:input radio status "Yellow":)
Green: (:input radio status "Green":)
White: (:input radio status "White":)
Template Page:
(:cell align=center bgcolor={$$:status}:)
Now I would like to edit - using Foxedit - this cell colour.
To do this my input Form looks like:
Red: (:input radio status "Red":)
Yellow: (:input radio status "Yellow":)
Green: (:input radio status "Green":)
White: (:input radio status "White":)
(:input hidden name=$:row '{$$(add {$:row} 1)}':)
And my template page looks like this:
(:cell align=center bgcolor={$$status}:){$:Status{$$row}} (:Status{$$row}:{$$status}:)
(:cell align=center:)[-({[foxedit section={$$row} form=form name]})-]
But in doing it this way I find I can set the colour using the input form, but the Edit function doesn't update the ptv.
Example: Using the input form to initially set the colour the page, after the input is made, looks like this:
(:cell align=center bgcolor=Red:){$:Status1} (:Status1:Red:)
However after clicking edit and changing the colour to "Yellow" the page looks like this:
(:cell align=center bgcolor=Red:){$:Status1} (:Status1:Yellow:)
i.e. the cell has the word Yellow written in it but the cell is still Red!
I can't figure out why this is so.
if you edit the PTV named Statusrowid then you need to post initially this as background value, i.e. your form template should have
(:cell align=center bgcolor={$:Status{$$row}}:){$:Status{$$row}} (:Status{$$row}:{$$status}:)
flash map integration?
Another question for you =). Got the last issue working well in the end, although the variable image size caused me some problems. No problem to put %width={$:PTV}px% though.
Now I am making a flash map to insert into the wiki, and different locations in the map should (if this is possible) show text based on variables from the pages generated by the Fox form. Is there a way to export to xml, or otherwise make the variables readable for my flash movie? MikeD? 2008-09-18.
I really have no idea, sorry! HansB
Hi! I have two questions regarding the Fox recipe.
1. I am using a table where posting a fox form creates a new row. Each row has a number, which classifies the PTVs of that row (eg. (:Name{$$number}:) becomes {S:Name1} for the first entry and so on). The row number is decided by (add {$FoxPostCount} 1). The problem with this, however, is when somebody deletes one row to add a new one. If row 3 of 4 is deleted, the last row and the new row will both be number 4. Is there a way to avoid this?
I would not use FoxPostCount, but use a dedicated hidden PTV, like (:rowcount: 0:) (initial value), and use that to calculate the number, and update the PTV when the form posts with the new number.
A suggestion what this would look like:
Template:
#foxbegin#
(:cellnr:){$$number}
(:cell valign=center:){$$name}
(:cell valign=center:){$:Born{$$number}}
(:cell valign=center:)[-({[foxedit section={$$number} form=Site.FoxTemplates#famform]})-]
(:cell align=center valign=center:)({[foxdelrange]})
(:Age{$$number}: {(sub {$Year} {$:Born{$$number}})}:)
(:Name{$$number}:{$$name}:)
(:Born{$$number}:{$$born}:)
#foxend#
Form:
(:foxmessages:) %comment For debugging with no redirect=1 set in form%%
(:table:)
(:fox unitlist redirect=1:)
(:foxadd put=aboveform template=FamilyTemplate target={*$FullName}:)
(:foxptv target={*$FullName} ptvfields=number :)
(:cellnr valign=center:)[+'''+'''+]
(:cell valign=center:)Name:(:input text name size=25 class=inputtext:)
(:cell valign=center:)Born: (:input text born size=5 class=inputtext:)
(:cell align=center valign=center:)(:input hidden number '{$$(add {$:number} 1)}':)(:input submit post " Add " class=inputbutton:)
(:foxend unitlist:)
(:tableend:)
(:number: 0:)
Thanks. Definitely better than my previous solution =). About the images: even if the age is 0, the width should not be 0px. So I should add another PTV, or a formula, that - as an example - can give the height as (20px+({$:Age1}*3px)). Is this possible, and should it be in the template or on the target page? MikeD?
Calculations will not work as part of the template. You can do a calculation with the appropiate markup expression as part of the form submission process, usually by using something like (:input hidden var {$$(expression...)}:). Note the two $$. Fox will evaluate this expression on submission, and you could post the calresult using {$$var} in your template. Without the two $$ the expression gets evaluated when the page is loaded. Alternatively you could use a markup expression as part of your page, and include any page variable you need. - HansB September 12, 2008, at 07:22 AM
Below are two lines from the form, the first one to calculate age works fins, while the second one to calculate height is not working at all. What could be the season for this? Whether I put $$ in front or not, it inevitably gets the value 21.MikeD?
(:Age{$$number}: {(sub {$Year} {$:Born{$$number}})}:)
(:Height{$$number}: {(add (mul (sub {$Year} {$:Born{$$number}}) 2) 19)}:)
what do you mean by "from the form"? In the template? Use a hidden input control to calculate the value of a variable, then use the var in your template. - HansB September 13, 2008, at 10:56 AM
2. I want to use a PTV to decide the size of a picture. Maybe I should ask this somewhere else, but it is the outcome of the abovementioned form, so I thought you might be able to help. The input variable {$$dateofbirth} is used to calculate the PTV {$:Age{$$number}}. The age should then decide the size of an image, but I have not been able to make this work.
Not sure where your problem is. Can you calculate the age, and set it as a PTV? Can you use such PTV for an image width or height css property? This latter may well not be possible, i.e %width={$:Age}%. - HansB
Hope you have some ideas, MikeD?, 2008-09-10
Ok, so I'm very impressed with the entire Fox recipe. It adds a lot of functionality to PMWiki. My question is, I'm looking for a PIM that would include the functionalities of Fox, but specifically I need something that would add a calendar function. I would like the people on my wiki to have a "personal" page that would include a calendar. Could Fox do something like this? Basically, their calendars would be included on their personal pages and would not be joined with each other. Thanks, Chris 8-25-08
You could combine PmCal with Fox, by using Fox forms to create PmCal pages. But you would need to create a new calendar group for every User. Or use a Fox form to add a line to the personal page, which includes a date and perhaps a delete link. A simple list can be created that way. I am not sure what you mean by a calendar on a user page. HansB August 27, 2008, at 12:31 PM
Hans, what I mean is that users will be creating a page for their families (in a sense similar to myspace). I would like them to have some tool where they could edit their own calendar where, for example, they could remind another of anniversaries, birthdays and other important events. This is super beneficial because they would also password protect their family pages so that only people that should see them, could. I need it, however, where people would have their individual calendars, instead of a community calendar. So, for example, I wouldn't want Family A to put a doctor appointment (which could be personal) on a calendar that would be seen by every other family. Thanks, Chris 8-28-08
Could you not have a group of wiki pages per user? That would make things a lot simpler. And each group can be password protected. At present there is no "calendar on one page" recipe. HansB August 28, 2008, at 06:34 AM
Thanks so much Hans. Got it all working perfectly!!!
THanks for the explanation Hans. Unfortunately it still is not posting the form information into the page bellow the header. It isnt going anywhere at all, just disapearing from the form.
http://www.botanybaywatch.com.au/pmwiki/pmwiki.php?n=Sighting.Marine-WeedySeaDragon If you type info into the fields then process it, the info just goes away to no where.
The main reason for me wanting the form to be in the header is so that it self populates when people make a new species page. therefor allowing them to report about the species straight away, and makeing less work for the site administrators.
Thanks again Hans. :)
I did a few changes, but discovered that you need to set FoxPagePermissions to allow Fox to add content in the group. Try $FoxPagePermissions['Sighting.*'] = 'add'; in config.php before including fox.php. HansB July 15, 2008, at 04:12 AM
Dear Hans, Thank you again for your help. I have tried to use (:fox formname target={*$FullName} put=top ...:) in the form and have still been unable to get it to work.
Correct me if I am wrong, but am I supposed to correct it with the relevant information from my site? i.e. (:fox form1 target=Sighting.{$Group}-{$Name} put=top ...:)
I am using it in this header: http://www.botanybaywatch.com.au/pmwiki/pmwiki.php?n=Sighting.GroupHeader
Which is then used as a header for this group of pages: http://www.botanybaywatch.com.au/pmwiki/pmwiki.php?n=Sighting.Marine-WeedySeaDragon
Will it just not work with the format that I am using for self generating pages?
Cheers... Carl :)
use (:fox form1 target={*$FullName} put=top:) (I just done it on your site and I think it works). {*$FullName} is a page variable and is rendered as Group.PageName. The * indicates it to be relating to the main page, not the GroupHeader. Dots ... I often use to indicate that there may be more markup parameters. And don't use 'form1' for all your forms on the same page, use different names! - HansB July 14, 2008, at 06:44 PM
Thank you so much HansB. The form works great!
Do you know if you can set a fox form into a common header for a group of pages and still have it post the entered text under the header? I have been able to post it into the header, but havent been able to get it to post the entered information into the main page (under the header). It seems that when a fox form is posted into a header it no longer works. Is there any code to tell the form to post the information into the main section of the page?
Try the fox form with this (:fox formname target={*$FullName} put=top ...:) - HansB July 11, 2008, at 07:56 AM
To whomb it may concern:
I am developing a wiki based Volunteer Marine Monitoring Program website
for my local area, Botany Bay. I am trying to write the code for a survey
form in wiki and am having no luck getting it to work. Can someone look
at the code and see where I am going wrong? Thanks in advanced.
Here is your form fixed! - HansB July 06, 2008, at 09:41 AM
(:fox form1:)
|| class=firstrow border=0 cellspacing=0 width=50%
|| || || ||
||Volunteer Diver (First Last Name)||(:input text Volunteer size=20:)|| ||
||Date (dd/mm/yy)||(:input text Date size=20:)|| ||
||Time of Day (24 hour time)||(:input text Time size=20:)|| ||
||Location Name (Dive Site)||(:input select Location Bare_Island_East :)
(:input select Location Bare_Island_West :)
(:input select Location Monument :)
(:input select Location Sutherland_Point :)
(:input select Location Steps :)
(:input select Location Leap :)
(:input select Location Other :)|| ||
||Length of Dive (Minutes)||(:input text Duration size=20:)|| ||
||Depth of Sightings (Meters)||(:input text Depth size=20:)|| ||
||Water Temperature (Celcius)||(:input text Temp size=20:)|| ||
||Number of Individuals||(:input select Individuals Nil:)
(:input select Individuals One:)
(:input select Individuals Few :)
(:input select Individuals Abundant :)|| ||
||Approximate size of Individuals (cm's)||(:input text Size size=20:)|| ||
||Other Notes||(:input text Notes size=22:)|| ||
|| ||(:input submit post "Enter":) ||
(:foxtemplate "||{$$Volunteer} ||{$$Date} ||{$$Time} ||{$$Location} ||{$$Duration} ||{$$Depth} ||{$$Temp} ||{$$Individuals} ||{$$Size} ||{$$Notes} || ||":)
(:foxend form1:)
[[#Report]]
!!!!Reports
----
||width=100%
||!Volunteer ||!Date ||!Time of Day ||!Dive Site ||!Length of Dive ||!Depth of Sightings ||!Water Temp ||!Number of Individuals ||!Approx Size (cm) ||!Other Notes || ||
(:foxprepend form1 :)
In fox.php the page number text used in multi-page output is hardcoded as 'Page' in two places. This means that one cannot translate fox-output to other languages using the normal $[Page] convention without changing the code. Could this be fixed for consistency? 18.06.2008, JHJ
I cannot find it. Can you give me version and line numbers, or in which error message? Thanks! - HansB June 18, 2008, at 12:02 PM
Sorry, in foxforum.php actually, lines 160 and 224. version 2008-03-30. - 19.8.2008, JHJ
okay, thanks! I updated foxforum.php to use $[Page] for internationalisations. - HansB June 19, 2008, at 10:37 AM
Hans, I am trying to create a search form for a (flat) database (a bib file using bibtexref, but this may not be important). I hand the parameter to the function as a page text variable. Since these are updated only after the page is written I have to hit the Submit button twice, which works but is not nice. I suppose I am doing this all wrong but couldn't think of something else. My problem would go away if ptvs were updated first. Is there a way to do this? Here is my code:
(:fox bib ptvtarget=Test/Test ptvfields=myyear:)
(:input text myyear {$:myyear} size=4:)
(:input submit post "Submit":)
(:foxend bib:)
bibtexquery:[all.bib][$this->get('YEAR') == ''][!$this->get('PUBDATE')][5]
bibtexquery is a function provided by the bibtexref recipe.
Thanks in advance for any help.
Rudi, May 17, 2008
Try adding redirect=1 to the (:fox ....:) markup, which will refresh the PTV in the page after posting. HansB
This works. Thank you so much!
Hans, I never did get my version of Fox ToDo all the way where I want it. I haven't really kept up with all your updates, but I was wondering whether you can tell me if there is now a way to accomplish the last step: deleting and posting with a single submit. Here is what I have so far:
- Post new todo items to a designated area of the page (for pending items)
- Select multiple pending todo items (with a checkbox) and post those to another designated area (for completed items)
What I still want to do is to delete the selected pending items at the same time that they are posted. If that is not possible, can you see another way to approach this so that I don't have to do two steps to move an item from one area to another? Here is the markup I am using right now:
!To Do
(:fox todo:)
(:foxtemplate (:input checkbox todocb[] '{$$todo}':) {$$todo} {[foxdelline]} [[<<]]:)
* (:input text todo size=65%:)(:input submit post Add:)
(:foxend todo:)
!!Pending Tasks
(:fox done:)
(:foxtemplate *{$$todocb[]}:)
(:foxprepend todo:)
(:input submit post "Completed":)
(:foxend done:)
!!Completed Tasks
(:foxprepend done:)
Pico May 17, 2008, at 01:39 PM
Alternative: I really should be just using PTVs with a replace to toggle values between pending/complete, on/off, etc., and then doing some type of a list (pagelist based on an array PTVs in the current page filtered by the value (pending/complete, or on/off).
Alternative Recipe: Here is some inspired (hopefully not unwelcome) musing on a recipe I have been imagining for a long time: Create another type of PTV definition that holds a binary logic value (on/off, or true/false) where you could iterate (an array?) to generate a listing of all true, or false, values. The markup for that recipe could use something really minimal, such as a pair of brackets, "[]", at the start of a line, like list markup, to generate input check boxes and PTV containing a binary value. The names of those binary PTVs could be determined by text immediately following the "[]" markup. Or, following the list markup definition, the names of the PTV could be based on a value assigned in a list in which it appears. For example, the first order (parent) level of a list could identify a PTV array consisting of the values that appear in the next order (child) items of that list.
So that an array variable called "VarableName[]" could have three pairs of values (logic, string) like this: False,First; False,Second; False,Third. A conditional testing for VariableName[]=False would return all three values, or pairs. The list could be hidden in a conditional to define posted values that get posted after (or before) a given (parent) item level. Default values could be set by markup arguments in the parent item, or by a three character markup string, e.g. "[+] / [-]" or "[_] / [X]", like this:
- []VariableName
- [-]First
- [+]Second
- [+]Third
So that a conditional testing for VariableName[]=True would return only the last two items.
Pico May 17, 2008, at 06:43 PM
Pico. I have not answered because I have no clever ideas for this problem of moving a line of text. Of course Fox can do several steps in one go: insert a line somewhere, and overwrite the original. Problem is how to identify it. Foxdelete works because it just replaces the line it is in with nothing. Some sort of foxmove link would be nice, but i don't know yet how to make the code for this. HansB May 19, 2008, at 06:26 AM
Hi, I'm getting this when trying to use ptvfields=something
Fatal error: [] operator not supported for strings in /home/....../cookbook/fox.php on line 1243
what have I messed up now?
thanks,
Taavi
Perhaps you are using illegal ptv names? If not I need to know more details about the form and the ptvs. HansB
table from fox input
Hi,
I'm trying to give input to a table, where the headings are fixed and the form is placed in the bottom row. The submit function is then supposed to create a new row between the form and the header, including an edit and delete link. I though I had set up something that could work, but apparently I have done someting wrong. The template looks roughly like this:
#foxbegin#
(:cellnr:){$$number}
(:cell:){$$name}
(:cell:){$$date}
(:cell:)({[foxedit form=Site.FoxTemplates#unitlist]})
(:cell:){[foxdelrange ]}
#foxend#
...and the form is placed inside the same number of coloumns with (:fox list put=aboveform template=(as above):) placed after the heading row. Ideally, the {$$number} should also be replaced by 1,2,3,etc and the total number should be a ptv. Is there an easy way I could make this work?
Thanks, MikeG? May 12, 2008, at 17:22 PM
Mike, you don't say what exactly is not working. Note that with your template you need to set in config.php $EnablePostDirectives = true; since the advanced table markup consists of directives (syntax (:....:) ). The total number of rows can be displayed with page variable {$FoxPostCount}. It counts the occurences of #foxbegin#. HansB May 13, 2008, at 04:20 AM
Correction: you don't need to set $EnablePostDirectives = true; in order to post markup directives which are part of the tenmplate! You only need it to allow users to post directives as part of their input. Sorry about the wrong advise before! - HansB May 13, 2008, at 05:00 PM
To add a row number automatically:
- Add a PTV as a counter to the page:
(:RowNumber: 0:)
- Add to the
(:fox ... :) markup: ptvfields=RowNumber ptvtarget={$FullName}
- Add to the fox form:
(:input hidden RowNumber '{$$(add {$:RowNumber} 1)}':) which updates the PTV with an increased number (you need to install Cookbook:MarkupExprPlus for this too)
- Change the form number field to
(:input hidden number {$$RowNumber}:) so th enew number is automatically used in the row (via the template).
I have set EnablePostDirectives, but when I submit, there is a processing period, but no content is added to the page. The form is placed like this:
(:cell:)"last cell of heading"
(:fox list put=aboveform template=(as above):)
(:cellnr:)(:input text number size=5:)
(:cell:)(:input text name size=25:)
(:cell:)(:input select date ...:)
(:cell colspan=2:)(:input submit post Add:)
(:foxend list:)
(:tableend:)
MikeG? May 13, 2008, at 04:38 AM
Perhaps page permissions are not set correctly? Add a (:foxmessages:) markup to see any error messages. Fox should be able to post to the current page, but adding target={$FullName} won't do any harm. - HansB
Thanks a lot for your help. Got most of this working now, apart from the row numbers. When I add the first entry, I get RowNumber=1, but if I try to add a second entry the number stays the same. Unless I leave the page or reload, in which case it works all right. Reload also adds a new entry identical to the last one. How can this be avoided? MikeG?
reload should never add a new entry!
Here is the form I used for testing:
(:foxmessages:)
(:table border=1:)
(:fox frm put=aboveform template=#tablerow ptvfields=number ptvtarget={$FullName}:)
(:input hidden number '{$$(inc {$:number})}':)
(:cellnr:)
(:cell:)(:input text name:)
(:cell:)(:input text date '{$Now}':)
(:cell:)(:input submit post 'Add Row':)
(:foxend frm:)
(:tableend:)
(:number: 0:)
last row number = {$:number}
(:if false:)
[[#tablerow]]
#foxbegin#
(:cellnr:){$$number}
(:cell:){$$name}
(:cell:){$$date}
(:cell:)({[foxedit form=Site.FoxTemplates#unitlist]})
(:cell:){[foxdelrange]}
#foxend#
[[#tablerowend]]
(:ifend:)
In config.php I added a definition for markup expression {(inc ...)}, which increases a number by one.
$MarkupExpr['inc'] = 'MxInc($args[0])';
function MxInc ($arg) {
if(!is_numeric($arg)) return $arg;
return $arg + 1;
}
I might add this in future to fox.php for conveniance. But using {(add ... 1)} from MarkupExprPlus is working just as well. The form template is on the same page, which is not ideal, but fine for the test. I have no idea how your foxedit #unitlist template works though.
The form adds a new row with the increased number. Note that I use here 'number' as input field name, which value is added by template {$$number}, and 'number' as a PTV name, which value gets used in the form with {$:number}. I called this RowNumber before. The last number shown with {$:number} will be one less the actual value, until the page is refreshed. One could avouid this by adding redirect=1 to the (:fox ...:) markup. - HansB May 13, 2008, at 10:27 AM
The {(add ... 1)} function seems to be working fine. I added redirect=1 and now the numbers update without any problems. Thanks for all the help, MikeG?.
So what stopped it posting in the first place? - HansB
Not sure. Could it have been the missing $EnablePostDirectives = true;?
I was wrong advising that this is necessary. It is not. Directive markup in the template will be posted in any case just fine. HansB
Will start inserting (:foxmessages:) markup in my forms :).
Note that by using redirect= Fox cannot display any message via (:foxmessages:). For debugging turn off the redirect parameter, so you stay on the same page and the page is not reloaded and messages wiped. HansB
Also not sure how the edit template will look as I haven't put that together yet, but each line in the table produces a set of pvt's (also with incremental numbers) which I then plan to base the edit form on. MikeG?
Good, that should be not too difficult then. Just add section={$$number} to the foxedit markup in the template, to give you a hook for each PTV in the PTV edit form you need to build. Use edit form fields like (:input text name=$:date{$EditSection} :). FoxEdit will pass the row number as {$EditSection} page variable, and 'date23' for instance will be the PTV name for the date in row 23. On FoxEdit about "Adding edit links to FoxForum posts" you find a template example working in this way. - HansB
Decided to use {$FoxPostCount} as the ptv, counting the number of entries. However, I wanted to have a comment form on the page as well, and the way it works now, comments are included in the same page and therefore also counted. Is there a way to exclude them from the {$FoxPostCount} calculation, or to have a separate page for discussion, with the form and comments included on the main page? How would this page be created? -MikeG?.
One problem using FoxPostCount for generating post numbers is, that if you use foxedelete as well, posts can be deleted and the next new post will get a number which may be used already. - To post comments to a different page use for instance a target parameter like target={$FullName}-Comments in the fox markup. - HansB May 15, 2008, at 05:59 AM
So the form creates a separate comment page, displayed on the main page by (:include {$FullName}-Comments:). However, the {[foxdelrange]}-link doesn't work when clicked from the main page, only on the {$FullName}-Comments page. I see you have discussed something like this further down on the page, but it's still not clear to me how to fix it... MikeG?
What happens when you click a delete link from the main page? Do you have a foxmessage markup to see error messages? - HansB
(:foxmessages:) displays "ERROR: Delete action was unsuccessful!" The problem is the deletelink that is created by the template for the comment page. When read through (:include ...:), it links to {FullName} instead of {$FullName}-Comments. MikeG?
In config.php you need to have $EnableRelativePageVars = 1; - HansB
javascript formcheck not working (i want to require an authorname)?
hi - formcheck doesn't seem to work for me with the following fox form:
(:fox cbox put=bottom template=Site.FoxCommentTemplate target={*$FullName}
formcheck=author redirect={*$Group}/MainPage cancelredirect={*$Group}/MainPage :)
... and later on, comes the author box:
(:input text author value='{$Author}' :)
currently, neither formcheck=author nor formcheck=1 causes fox on my site to ask for an authorname, and any user can still submit a comment w/o entering one.
??
thanks! overtones99 May 07, 2008, at 12:23 PM
Fixed now. Note formcheck=1 is not valid. You need to specify form field names, separated by commas. If you don't want this simple javascript check, but proper php validation, with custom messages, use markupo (:foxcheck fieldname ...:) (See Fox#foxcheck HansB May 07, 2008, at 04:08 PM
thanks. both seem to work alright now - however there seems to be a problem with foxcheck when checking for captcha:
(:foxcheck name=author,comment,captcha msg='required field' :)
and then later...
(:input captcha class=inputtext:)
when checking for captcha, it won't post the comment even if the captcha field is filled out correctly...
??
overtones99 May 07, 2008, at 08:16 PM
This is because (:input captcha class=inputtext:) is not a normal input markup. In particular the name of the captcha text field is not 'captcha', but normally 'response' (it can be redefined). So (:foxcheck response ... :) should do the trick. If you want to name the field 'captcha', add to config.php: $CaptchaName = 'captcha'; - HansB May 08, 2008, at 02:21 AM
that did it. thanks again for the umpteenth time!
overtones99 May 08, 2008, at 03:06 AM
#anchors not working in redirect= field...
hi. i'm trying to get my FoxCommentBox to redirect to the comment section at the bottom of a page. i'm setting redirect=MyGroup/Index#comments, and the anchor seems not to be appended to the path.
(:fox cbox put=bottom template=Site.FoxCommentTemplateWhite target=Cookbook.Fox-Talk
redirect=MyGroup/Index#comments cancelredirect=MyGroup/Index#comments:)
is this working on your end? i'm currently running the latest version of Fox (5/1/08)
thanks. overtones99 May 01, 2008, at 12:53 PM
To redirect to an anchor position one needs to supply a full url using the standard url syntax, not a short url. So use redirect={$ScriptUrl}?n=Group.PageName#anchor . cancelredirect does not work with anchors or full urls, but only with Group.PageName. - HansB May 01, 2008, at 03:20 PM
great. indeed it works. thanks. only issue now is purely aesthetic - the address for the page looks like http://blah.com/?n=Blah.Index#anchor even though my pages are set to do clean URLs. but it doesn't bother me, as long as it works.
thanks!
adam, overtones99 May 01, 2008, at 04:37 PM
from Hans:
Please see latest fox update, which improves the redirect greatly.
Redirect to an anchor is possible now, for instance like
redirect=Group.Page#anchor
- HansB
fox delete page action...
hi. i'm having trouble getting a 'delete page' action to work (as described on FoxPageManagement).
i created a page on my main site (let's called it GroupOne/Blah), and as a test i am trying to delete it with the page action provided in the fox documentation under "One click page delete action link" - the only difference is i changed the permissions to 'admin':
if (CondAuth($pagename,'admin')) {
$EnableFoxUrlInput = 'true';
$FoxPagePermissions['*.*'] = 'all';
}
and in SiteAdmin.FoxConfig, i have:
*.*: add,delete
GroupOne.*: add,delete
(if this is even necessary??)
when i click the delete link, i'm redirected to the main group page, GroupOne/Index (as expected), however, if i now go and type in GroupOne/Blah, it comes up just as bright and alive as it was before, as it wasn't deleted. (this happens if i change the auth to plain 'edit' as well.)
any idea what i might be doing wrong?
i have the following fox files installed:
foxnotify, foxdelete, fox
thanks, adam
overtones99 April 26, 2008, at 02:00 AM
Add &target={*$FullName} to the link url parameters. I updated the example accordingly on FoxPageManagement. - HansB
hrm - seems like that would do it, but it still doesn't delete. it now redirects correctly, however... i wonder if it works on your end? overtones99 April 27, 2008, at 01:08 AM
update: having now deleted *.*: add,delete from my SiteAdmin.FoxConfig, the delete-action now works like it should(!). i haven't tried it yet, but i'm presuming that putting *.*: all in there might have worked as well... thanks! overtones99 April 27, 2008, at 01:46 AM
Additional fox deletion problems
and in a similar area, i'm also unable to delete multiple pages using the Fox code from the bottom of FoxPageManagement. everytime i check off a page or two to delete, i get the msg, "PERMISSION DENIED to replace on JoeSchmo.JoeSchmo-Blah!"
any idea what i might be doing wrong?
i've currently got the following settings:
$FoxNameFmt[] = '*.*';
$FoxAuth = 'read';
$EnablePostDirectives = true;
$EnableFoxDeleteMsg = true;
$FoxDeleteMsg = "Are you sure you want to delete this message?";
$EnablePostCaptchaRequired = 1;
if (CondAuth($pagename,'edit')) {
$EnableFoxUrlInput = 'true';
$FoxPagePermissions['*.*'] = 'all';
}
and then all my fox files are loaded, as well as powertools.php (which i have loading after fox loads - is that a problem?)...
thanks again for all your help.
overtones99 April 26, 2008, at 02:23 AM
This looks like a $FoxPagePermissions problem. I don't know why $FoxPagePermissions['*.*'] = 'all'; is not recognised. Try for testing without the condition. Also try a group specific variation. - HansB
thanks. i think i figured it out. in addition to my $FoxPagePermissions being set in config.php, on SiteAdmin.FoxConfig i also had *.*: add,delete listed on there... in calling both, it appears the FoxConfig page short-circuited it. now, with it missing from FoxConfig, it deletes absolutely perfectly... what a great little tool. thanks! overtones99 April 27, 2008, at 01:46 AM
Risk of Fox Inclusion in main distribution...
Hi - just wondering - how much risk is there in parts of Fox someday being included in the main distro of pmwiki? and if it ever is, do you think that the syntax would then change, i.e. all the (:foxwhatever's ...:) changing back to the originals? just wondering...
overtones99 April 25, 2008, at 02:22 PM
I don't think this will happen. Pm created PmForm. This may still improve, but I don't think it will ever be expanded to post to multiple target pages or other special things Fox does. And Fox is far too complex to have the slightest chance of being absorbed in the PmWiki core. Even PmForm will not be added to the distribution I think. HansB
Lock/hide forms
Hi! I've been using Fox forms to update different sections of a reporting page, with bullet points and progress indicators. Is there a way, either on a specified date or by following a command link, to stop editing abilities and (1) export the headers and text to a new page, or (2) remove all input fields and forms from the page?
Mike G? April 25, 2008, at 04:55 AM
There should be no need to have the form on the page itself. It could be on some template page and either be included via a (:include ...MyForm :) or called via a FoxEdit link, and you can disable these with conditional markup (for instance after a certain date). - HansB April 25, 2008, at 07:32 AM
Thanks. Have set up FoxEdit links for each section on the page. The date conditional doesn't help me as long as I can't set time. Could you give me another example of conditional markup that could serve this purpose? To use authgroup doesn't work as all users can read and edit.Mike G? April 25, 2008, at 10:25 AM
what condition do you really need, exactly? - HansB
I'm using ExportDOC to save the page in Word format upon completion. What I need is a button that can disable the edit links and then, with [[{$Name}?action=doc]], export the final document, in one or two operations. Mike G?
If foxedit links or other form elements or include markup isadded to the page by Fox via a template, then you can add foxdelete links as well, either with range markers as a foxdelete range link, or if it is a single line as a foxdelete line link. Foxdelete links need to be added via template, a later addition does not work, as Fox adds a range or line id key, which the foxdelete needs to delete just the right line or range.
Template for foxdelete link which deletes the range marked by the markers, including itself:
#foxbegin#
....
{[foxdeleterange ]}
.....
#foxend#
- HansB
Fox Permissions
Hi - i've been looking at the permissions examples on the Fox cookbook page, and am wondering - is there a way to set separate 'read','edit' and 'admin' fox permissions for pages on SiteAdmin.FoxConfig?? or is it only possible to do this in config.php (as shown in the example on the Fox cookbook page)?
thanks, adam
overtones99 April 24, 2008, at 09:16 PM
At present you cannot set $FoxAuth values in page FoxConfig. You can only set $FoxPagePermissions page pattern / values within FoxConfig. - HansB April 25, 2008, at 02:16 AM
thanks!
Custom Fox Delete Msg?
can one set the confirmation msg that pops up when $EnableFoxDeleteMsg is set to true? right now mine is blank, except for the URL basename...
thanks
overtones99 April 24, 2008, at 11:26 PM
$EnableFoxDeleteMsg = true; will enable the javascript delete confirmation. The default message is: "Please confirm: Do you want to delete this post?" Try setting $FoxDeleteMessage to the message you want. - HansB April 25, 2008, at 02:16 AM
i'm on a mac, and in both firefox & safari the only message that shows by default is: "The page at http://blah.com says:", and then nothing following it. adding $FoxDeleteMessage, doesn't work, but $FoxDeleteMsg DOES. thanks!! overtones99 April 25, 2008, at 02:12 PM
Input Value and Label
I want to make a simple form for progress report. (:input select stage 1 label="Assessed":) is the markup used, with 5 different stages to choose from. Is it possible to output both the stage number and the label as variables using Fox?
Thanks, Mike G? April 23, 2008, at 02:19 AM
'label' is not directly available as an input value. So you may try something like this example test form:
(:fox frm foxaction=display:)
(:input select choice "1 Assessed" label="Assessed":)
(:input select choice "2 Tested" label="Tested":)
(:input select choice "3 Approved" label="Approved":)
(:input hidden stage "{$$(substr '{$$choice}' 0 1)}":)
(:input hidden type "{$$(substr '{$$choice}' 2)}":)
(:foxtemplate "{$$stage} {$$type}":)
(:input submit post Enter:)
(:foxend frm:)
(:foxdisplay frm:)
This uses {(substr .... )} markup expression to extract parts of an input value ('choice') (which combines both original value and label) and assigns it to a different input variable (hidden field name 'stage' and 'type'). Observe all the quote marks and $ signs carefully. HansB April 22, 2008, at 05:15 AM
Works! But I am using one form to generate the pages for each unit, and a second form in the template for status updates. So the second form works well in the template, but when the page is generated, the {(substr ...)} markup is processed, and disappears. How can I avoid this? -Mike G? February 09, 2012, at 12:47 PM
If you want to post form templates, without having the replacement variables evaluated, use $$$ instead of $$ for each {$$var}, i.e {$$$var}. I hope this works for {$$$(expression)} as well. If not, I have to do some work on this. - HansB April 23, 2008, at 02:31 AM
Conditional markup in fox form
Hi! I'm new to this and may not be doing things the easiest way always, but I am testing out the wiki as a project tool, and setting up a form for input of new registrations. The heading of each entry should contain "sector" "building" "floor number" and "door number", separated by a dash. Some entries don't have the door number, and should therefore just contain the other 3 variables. What I put in the form is this:
(:if equal {$$unitdoor} "":)
(:input hidden unit "{$$sector}{$$number}/{$$unitfloor}":)
(:else:)
(:input hidden unit "{$$sector}{$$number}/{$$unitfloor}/{$$unitdoor}":)
(:ifend:)
Still, {$$unit} exports with a dash at the end, regardless of whether {$$unitdoor} exists or not. There is hopefully a very simple solution to this, but try-and-fail is not helping me anymore.
Thanks! Mike G? April 19, 2008, at 12:30 AM
Such conditionals are evaluated by PmWiki when the page gets created, not when the form gets submitted. fox has no built-in method using conditionals in the markup. But it can be done with the help of MarkupExprPlus. Install this recipe and then construct a markup expression which gets evaluated when the form gets submitted. Usual markup expressions get evaluated when the page gets created, but by using the syntax {$$(expression ...)} as a hidden input form value Fox will evaluate it when the form gets posted.
So perhaps you need something like this (all on one line!!):
(:input hidden unit "{$$(if (test equal '{$$unitdoor}' '')
'{$$sector}{$$number}/{$$unitfloor}' '{$$sector}{$$number}/{$$unitfloor}/{$$unitdoor}' )}" :)
Note I have not tested this! HansB April 19, 2008, at 01:18 PM
Beautiful. Works like a dream. Thanks for the quick reply! Mike G? April 19, 2008, at 01:45 PM
Posting to Fox-Comments
Hi - i posted a question to to Fox-Comments and it got removed a day later. I wonder, what is the desired procedure for posting on this page? (It's odd having two places [here and the list] to potentially post questions)
- is it preferred that we send our questions first to the pm-wiki users list?
- would it ever be desired to post here and NOT on the list?
- are there some questions / posts that are more appropriate for this page than others? and ones that would be more appropriate for the list?
Thanks!
overtones99 March 30, 2008, at 05:27 PM
I am sorry. I thought you would have noticed, but I moved your very relevant questions to FoxNotify-Comments?, and replied there, since they related specifically to FoxNotify. I try to keep questions to the relevant Fox application or sub-module if possible, and keep this page for all general Fox specific issues. I don't mind really if questions get posted on Comment pages here, or to the user list. The user list is a little more direct and may get a faster response (but I do monitor all the Fox pages). The user list also offers direct email response, which may be better for possibly more lengthy correspondence. My apologies for any confusion! HansB March 30, 2008, at 05:50 PM
oh great - didn't know that page existed! : )
i will take a look - thanks!
overtones99 March 30, 2008, at 06:08 PM
Fox examples?
Hi,
is there a page somewhere with a collection of working examples (i.e. not just code) of how Fox can be used?
thanks! overtones99 March 12, 2008, at 11:26 PM
You can find a number of working examples on my site. See http://softflow.org/design/Fox/Fox, and also the Forum on my site is running with Fox. HansB
thanks. wondering if it might be appropriate to put links on the bottom of the main fox page to examples like those on your site? it's great to read about what Fox can do, but would be evermore enticing (and might make more sense to noobs like myself) with links to a couple examples sitting there ready to be clicked. just my 2cents.
thanks!
overtones99 March 15, 2008, at 01:24 AM
Hi,
this is probably a dumb question, but I just can't get fox to work properly. If I create a page with the following content, just nothing happens if I push the GO button:
(:fox mytest foxaction=display:)
(:foxtemplate "'{$$arg1}'":)
(:input text arg1:) (:input submit post GO:)
(:foxend mytest:)
-- (:foxdisplay mytest:) --
If I add the line (:foxappend mytest:) to the page, regardless of its postion, everything works as aspected, i.e. arg1 shows up. What is it that I missed here? Or, if this should work without foxappend, where would I start searching for the error?
Thanks
foxaction=display outputs to markup foxdisplay, so foxappend should not be used or needed. you need the latest fox.php for foxaction=display, please check! Otherwise your form should work. For error reporting you can add markup (:messages:) at the top at the beginning of a line. The foxtemplate line should not need the ' '. HansB February 29, 2008, at 07:15 AM
Thanks four your help! When adding (:messages:) at the top, it gives me "PERMISSION DENIED to display on Main.My!". I tracked this down in fox.php where it seems to me the variable 'strcheck' does not find a match. If I append my page with something like (:foxallow:) or putting an #top in the statement like this: (:fox mytest #top foxaction=display:), all works fine. I probably just missed some initial authentication? I tried all three options for "auth permission level" (edit,read,ALWAYS) at the top of fox.php, but this did not changed anything.
Whenever you get a Permission Denied error there is an issue with page permissions not being configured rightly. This is done with setting $FoxPagePermissions for the appropiate page pattern and to the foxactions one wants permitted. BUT it should work to display on the same page as the form is. So I will see if I can cure this bug for the next release. Thanks for your investigation and reporting this issue! HansB
PS: To fix this bug remove (#prepend|#append|#top|#bottom) from function FoxPagePermission near the end. I hope this does not invite really undesired foxactions when posting onto the same page. I need to think this through a bit. It may be better that page permissions need to be set, without excepting the page with the form?? HansB
Add a Link Downloads pmwiki.php
Hi, I am trying to use select page to add a link at the bottom of the page. The template looks fine, but when i click 'add a link' mozzilla tries to open/download pmwiki.php.
On PageListTemplates
[[#selectpage]]
(:template each:)(:input select pagelink[] "[[{=$FullName}|{=$Namespaced}]]" "{=$Namespaced}":)
(:template last:)(:input submit post "Add Link":)
[[#selectpageend]]
On Main.Test
(:fox selectcategory:)
(:foxtemplate "*{$$pagelink[]}":)
(:pagelist fmt=#selectpage group=Category name=-HomePage:)
(:foxend selectcategory:)
In config.php
$FoxAuth = 'ALWAYS';
$FoxNameFmt[] = '*.*';
$FoxConfigPageFmt = '{$SiteGroup}.FoxConfig';
include_once("$FarmD/cookbook/fox/fox.php"); // fox
Can you please let me know what you think the problem is.
thanks x
The input submit control should be in the fox form, not the pagelist template.
and in config.php instead of $FoxNameFmt use
$FoxPagePermissions['*.*'] = 'all';
Thanks for your help. I changed it, but when I click Add Link, its still tries to open up pmwiki.php. Is there some permissions I need to set somewhere?
I don't think so. But since you added your reply here above the following code I like to ask if you changed the pagelist template and the fox form using the code below, and not just the config.php? If you did, do you use a recent new version of fox.php? HansB
I did change the pagelist template, fox form and confi.php file. I downloaded fox.php from http://www.pmwiki.org/wiki/Cookbook/Fox within the past week so I believe its it the most recent version.
Pagelist Template
[[#selectpage]]
(:template each:)(:input select pagelink[] "[[{=$FullName}|{=$Namespaced}]]" "{=$Namespaced}":)
[[#selectpageend]]
Fox Form
(:fox selectcategory:)
(:foxtemplate "*{$$pagelink[]}":)
(:pagelist fmt=#selectpage group=Category name=-HomePage:)
(:input submit post "Add Link":)
(:foxend selectcategory:)
HansB February 14, 2008, at 04:57 AM
Problem after update from October 2007 version
After an upgrade from a version from October 2007 (around the 20th), my add-a-news-entry-page form fails to add forms. What happens with the new version of fox is that an error-message about the target page not existing is being displayed. After a downgrade to my old version, everything works fine again.
(:fox newnews template=News.Template redirect=1 :)
(:input hidden author value="{$Author}" :)
'''Title:''' \\
(:input text target size=30 value={$Today}- :) (e.g. ''{$Today}-MyNewsTitle'')
...
(:foxend newnews:)
I'm trying to add a news page while being logged in as admin user, with FoxAuth set to edit.
Any help would be greatly appreciated - Nyhat February 9, 2008
It should work, the target page does not need to exist, it will be created. In the form above you do not give all details though. Try this form and see if it works (your form a little simplified):
(:fox newnews redirect=1 :)
(:foxtemplate "New News Page...":)
(:input hidden author value="{$Author}" :)
'''Title:''' \\
(:input text target size=30 :)
(:input submit post 'create page':)
(:foxend newnews:)
Fox template markup \n is NOT converted into a new line.
For some reason all I get is "n" instead of an actual new line when I use "\n". No big deal but very weird. Don't know how but could it be a server thing? My host is extremely restrictive. Wasim February 06, 2008, at 03:10 AM
Normally you would not use \n in Fox templates. You use standard wiki markup and {$$Var} replacement variables. If I type \n here it will also just be shown. And linebreaks will just be linebreaks. I use \n in FoxNotify email templates, which is a very different output. And sometimes in php scripting for formatting output. HansB February 06, 2008, at 02:29 AM
Fox's delete button breaks PmWiki's email notification system for me
Pressing Fox's delete button causes duplicate emails to be sent out from my system for pages that I've set up for email notification. (I use PmWiki's NotifyList.) If I delete the same lines using PmWiki just one email notification goes out (the correct behavior). - RandyB February 4, 2008
Notify and Fox delete work fine for me on my site, i can't see the problem. HansB February 05, 2008, at 03:53 AM
Thanks so much to Hans for helping me track down the bug, and to Petko for suggesting a clean workaround. For anyone else who encounters this problem, enable Notify with this conditional in config.php:
if($action!='foxpost' && $action!='foxdelete' && $action!='comment')
{
$EnableNotify = 1;
}
- RandyB February 13, 2008
Interferrence with changed Default pages
Not a question and maybe too specific, but I thought maybe this info might be useful in case it happens to someone else: I changed the default group from Main to About and the default page from HomePage to Main ($DefaultGroup = 'About'; $DefaultName = 'Main';). This did not work properly, in that the page shown as start page was still Main.HomePage. After some testing it seems like the problem was that Fox was included in farmconfig.php, and the default changes in config.php, so after Fox: Moving include_once("$FarmD/cookbook/fox/fox.php"); in the config file below the default changes fixed it.
Anke January 10, 2008, at 11:47 AM
The fox.php script calls function ResolvePageName, just in case it needs this. And ResolvePageName shall only be called after the changes you made to $DefaultGroup and $DefaultName. So as you discovered it is best to include the script only in config.php after the changes. I think it is a good idea to include any recipe only in config.php, and not farmconfig.php, to be on the safe side. HansB
Hans,
I'm confused about the way $ScriptUrl works in the FoxDeleteMarkup function, and I know you were just working on it. I have created a blogging system wherein the comments are contained in a separate page (e.g. Comments.Group-Name) but are entered and displayed on the post's page itself (Group.Name). In fact, ?action=browse on a Comments.Group-Name page auto-redirects to Group.Name--so people never visit those pages (search engines dislike repeated content). So- I need a {[foxdelrange]} that produces the special Comments.Group-Name url--which is where the text is coming from anyway... At the moment, the url produced is the Group.Name url.
JonHaupt December 21, 2007, at 09:53 PM
Thanks for your alert, Jon! I myself was confused, and bungled the last change. I have now fixed this bug, and the delete links and buttons should work with clean urls and without and correctly point to the target page. I added a switch checking for $EnablepathInfo and setting a TargetPageUrl. HansB December 22, 2007, at 03:33 AM
Thanks, Hans. It works on my blog, so I've gone ahead and updated it. I also have a test site, which for some reason it doesn't work on... That site also uses clean urls, but they are in the style http://blah.com/pmwiki instead of in the root directory as they are in my blog. So $ScriptUrl is http://blah.com/pmwiki but the urls produced by {[foxdelrange]} are http://blah.com/Comments.Group-Name without the /pmwiki. I checked to make sure I'd set $ScriptUrl correctly and $EnablePathInfo=1... so I'm still a little confused about that. JonHaupt December 22, 2007, at 11:38 AM
Thanks, Jon! I forgot to declare ScriptUrl global in the FoxDeleteMarkup function. Fixed now. HansB December 22, 2007, at 01:30 PM
Excellent, thanks! By the way, I've been using Fox to make a lot of projects easier lately--it really is a great system. - JonHaupt
TextSection()
Hello, I just installed Fox on my wiki and this is is what turns out (trying the FoxCommentBox):
Fatal error: Call to undefined function TextSection() in [...]/cookbook/fox/fox.php on line 453
Ps: Thank you for pmwiki, I just needed something like that.
- Nick
You need to use PmWiki 2.2.0 beta 45 or later. Function TextSection was added only then I think. HansB December 16, 2007, at 02:56 PM
More on ToDo and Picklists
Hans,
I have gotten pretty close to where I wanted to get to using fox for todo and pick lists lists and I am wondering if you might have any ideas on how to go about the final step:
- I use fox to process an input text box to generate input checkbox lines that are posed to the section called pending tasks.
- Note the input checkboxes use an array for the name
- I then use fox to process those input checkboxes to post one or more items from the pending section down to the completed section.
- Having gotten that far do you see anyway to use fox to delete multiple lines from pending section?
- The fact that I am using an array for the pending checkbox items makes me think that there might be some way, short of clicking each delete link, to delete the lines identified by checked values in the array.
I posted a working example on your site at Test/FoxToDoTest
Pico December 08, 2007, at 02:07 PM
Pico, I can't see a way right now to have one form line deleted while it posts another line. Maybe with a fox filter function, but it need s to launch the delete action after the new content is added. I need to think on this. HansB December 08, 2007, at 04:17 PM
Hi,
I successfully used commentboxplus and $BlocklistActions['comments'] = 1 in my config file against spam. Now I'm using fox for comments and it seems that blocklist doesn't work. At least I get the same spam in comments, I had before using blocklist. Is there a special trick or a special order neccessary in config.php? Or doesn't fox work with blocklist?
I'm using fox version 2007-11-19, pmwiki-2.2.0-beta63 and build in blocklist.
Comments are written to special pages, e.g comments for "page1" are witten to "page1-Kommentare". Maybe that's a problem?
Thanks, NH
Please try $BlocklistActions['foxpost'] = 1; in config.php, and let me know if this works, as I have not tested blocklist with Fox, but would really like to know! Thanks! HansB November 25, 2007, at 06:36 AM
I made a few tests and blocklist didn't work with fox. Blocklist works with fox-forum. A quick and dirty hack is to insert the line
Blocklist($targetname, $addstring);
in fox.php function FoxAddEntry after
$addstring = FoxTemplateEngine($targetname, $template, $fx, '', 'FoxAddEntry');
But this is not tested very well and side effects may occur.
NH
If you add $BlocklistActions['foxpost'] = 1; to config.php then blocklist will act on anything posted in a form field named 'text' (this is the reason Blocklist works with FoxForum: FoxForum uses a textarea input box named 'text'). To make Fox more complient, so all postings in any field will be checked, it is necessary for the present Fox version to edit fox.php and add after ca line 367 (in the function FoxAddEntry), starting with:
$EditFunctions = array(... and before line starting UpdatePage(...
this:
global $EnableBlocklist;
if($EnableBlocklist)
array_unshift($EditFunctions, 'CheckBlocklist');
fox.php is now updated with this. HansB November 27, 2007, at 03:08 PM
Yes, this works. Thanks for patch (and scripts). NH
Summary= Argument: use an input field csum
How about adding summary= argument that populates the summary page variable on a page save? While you are at it, you could add an author= argument that populates the author field. Why? As I use fox more and more for changes the recent history conveys less information. With these arguments I can automate the population of these page variables to ensure that the recent history stays meaningful.
Pico October 10, 2007, at 05:17 PM
I am not sure what you like to achieve. If your form has a field which sets author, this will show in RecentPages. A summary can be provided by a field which sets csum: (:input text csum:) or (:input hidden csum "Comment added":) to have "Comment added" appear as change summary in RecentChanges when a post is made. Or use (:input hidden csum {$$heading}:) to supply a summary from an input field heading. csum will be used for the LastModifiedSummary var in RecentChanges. Without input for a summary you won't get any :-) . HansB October 11, 2007, at 06:52 AM
Thanks. I was focused on the fox directive and arguments and forgot to check the input directives.
Pico October 11, 2007, at 07:24 AM
Fox Shoutbox
Check it out - Shoutbox in the sidebar using this recipe. KMcC September 27, 2007, at 01:20 AM
Select multiple
Can fox recognize and make use of the multiple argument on select inputs? I have tried it when posting links to a page and only one of the selected items is posted. Would it be possible to have an array process an input selection so that more than one item could be specified and acted upon?
Pico September 23, 2007, at 05:36 PM
I updated fox.php to handle array inputs properly. I hope I have not broken normal behaviour! Use in the select form name[] as the select form name, and in your template use {$$name[]}, i.e.:
(:input select name=abc[] 1 alpha size=3 multiple:)
(:input select name=abc[] 2 beta selected=selected:)
(:input select name=abc[] 3 gamma :)
HansB September 24, 2007, at 11:51 AM
Thanks, it works great and does not seem to break anything that I have discovered.
Pico September 27, 2007, at 10:05 AM
Delete links feature request
Could the delete link feature be made to allow a deleted line to be archived (cut and pasted to a new location) instead of simply being deleted? If so, then a configuration setting could specify the archive location (where page variables could refer to the current group or page) and a directive such as (:foxappend archive:)could specify where on the page the archived line would be pasted.
Archiving deleted lines could be useful for todo or next action lists to indicate what items have been completed, by relocating them to a section that lists completed items.
Pico September 23, 2007, at 05:33 PM]
Alternatives
If archiving is not where you want to go, how about a link that allows you add a style (such as strikeout) to the current line? See Less Simple To Do. Or a check box that can be selected and unselected?
Pico September 29, 2007, at 08:03 AM
I would prefer a more general solution: I like to enable Fox to post fox forms defined in a template. That would allow all kinds of custom solutions. To do so requires modification of fox.php so replacement variables are handles differently if they are to be part of the posted fox form. I wonder if it is good enough to have Fox check if a replacement variable (in a template) has a corresponding field name in the form, in which case the replacement will take place. Otherwise no replacement will take place and the variable will be inserted instead. would that give rise to other problems? HansB September 29, 2007, at 09:08 AM
Yes, your more general solution sounds better, if I understand it correctly. Is the replacement variable just a value that toggles to direct whether to use a different portion of the template, or is it more like a replaceable PTV (like PM uses in PmForms)? In either event would it work when there are multiple items posted in a single page (would the variable require a unique name for each instance, or would it use the #foxbegin# like an anchor reference to distinguish one instance of the replacement variable from the next? Note that with PTV you can distinguish multiple instances on the same page by adding a reference to an anchor between the page name and the PTV name.
Pico September 29, 2007, at 09:26 AM
Note that #foxbegin# ... #foxend# does not provide unique IDs for field names, but only serves to provide unique section ID for the use of delete links and forms, if such are used in the template. If one wanted to post multiple fox forms, one would need to give each form a unique form name somehow.
Oh, I just saw your post to the mailing list here and I better understand your more general solution. Can Fox post regular input (or PmForm inputs) that use PTV through a Fox template, or does the current limitation apply to those as well as to Fox forms?
Pico September 29, 2007, at 09:35 AM
I have now implemented a solution which requires use of {$$$name} syntax in the template in order to post a replacement variable, i.e. {$$$...} gets posted as {$$...} and not replaced with a value.
PTVs will be posted as they stand. The problem was only with Fox's replacement variables. HansB September 29, 2007, at 01:10 PM
I am slow. Can you offer any hints about how I can use this new syntax to add a status functionality to posted add/delete (ToDO) lines? Thanks.
Pico September 29, 2007, at 06:39 PM
I am slow too! The changes are not enough for what you wish to achieve. I think Fox needs a genuine capacity to edit page sections. This was on my wish list anyway, and I will try to develop it. HansB
Question: Flash & video in comments?
Is there a way to use recipes for Google Video/YouTube/Flash/Quicktime in comments?
If you use one of the recipes to embed flash etc. into a wiki page, then you would need to enable posting of directives for Fox, so you can use embeding markup in a comment: $EnablePostDirectives = true;
Problem: Fox page permission settings ( I think!)
I am not able to delete any content using deleterange , deleteline markup. Here's my site. http://eatpotato.com/index.php?n=Main.HomePage
I set permissions in Site.FoxConfig, and local.config files, but still no changes! Any suggestions?
You may need to set in config.php: $EnablePathInfo = 1;
HansB July 24, 2007, at 01:51 PM
One more data collection question
Is it possible to make fox form erase former data? So that it don't add new entries to previous but deletes them. I changed the place of the public form hope it is now useable.
Fox does not delete content, it will append or prepend content. An exception is made with FoxForum which contains a foxforum.php script, which defines a ptvreplace filter. With that Fox can replace PTV values. HansB July 14, 2007, at 01:42 PM
http://taavi.org/twwk/pmwiki.php/Vorbis/Vorbis
Something happened to Categories - they don't work anymore. Could it be those conditions for nonexisting tags? Formely Categories did work right. Or is it this way to use two forms to make pages? Page names are just the same way as before: artist-album-track. So if I have a page RaymondHughes-LoveSong-02 and in that page category link to Raymond Hughes, it takes me to page Category/RaymondHughes. But the links in that page don't work.
I do not know. I have not studied your pages, sorry! HansB July 14, 2007, at 01:42 PM
Taavi
Data collection question
I try to make up form to collect metadata for flacfiles. My form and my question are here:
http://taavi.org/twwk/pmwiki.php/Vorbis/Vorbis
Taavi
Taavi, I could not use your site! Here are my answers:
- To retain values in fields try the local customisation describes under $InputValues: InputDefault#values
- To exclude empty fields being shown on target pages use conditional markup on the template page which checks the field is not empty, like this:
(:if ! equal {$$performer1} "":)Performer: {$$performer1}
(:if ! equal {$$performer2} "":)Performer: {$$performer2}
(:if ! equal {$$performer3} "":)Performer: {$$performer3}
(:if:)
HansB July 12, 2007, at 09:59 AM
Thanks
The conditional markup you suggested worked fine. I got my form working too but I had to do it with two separate forms in the same page. First one using pmform recip and second one using fox. Complicated perhaps but it works. I tried to make the page and form usable for everyone but didn't manage. Here we see how secure PmWiki is!
Taavi
Guibuttons
If in a post a user enters a link to new wikipage and this page is then edited, then there seems to be a confusion as which buttons to use? The guibuttons directory is still (incorrectly?) used, but guiedit buttons are displayed. As only some buttons exist in both directories, we get a partial display. Using only one or the other everywhere is probably best, but not necessarely desirable in all cases. -JHJ
This seems to be a GuiButtons question (used in the fox forums). Perhaps we can move it there? I will think about this though, but have no immediate answer. HansB
Internationalizations
It seems that Fox is not quite set up for internationalizations yet? In the Forum I added the $[...] convention to all text strings in all templates and files and then added the appropriate translations to the XLPage-pages. This worked fine, but should not at least the $[...] convention be included in the standard distribution, so we don't need to do the substitutions after each new release? -JHJ.
Sorry, yes I have not included internationalizations, yet. Fox and its various applications are still evolving and not polished at all yet. There seemed to be little point in providing XL support, if strings used are still changing. It needs to be more stable first. HansB
Login No Password (Author / Guest List)
I want to record guest visits. I put a fox comment box on the front page of my site. I copied the code for the comment box and took out header, message. And I copied the template: Also removed the header and message codes. Templates were put in the default locations. I don't understand fox. That's about the extent of my web design knowledge (copy and paste). I followed the recipes. I redirected the target. I put the code to authorize all fox posts in my local config (I have a sitewide admin password and all pages locked to admin editing). I've succeeded in prepopulating the author form (on subsequent visits), authors show up on my stats page, and their names are already filled in on the forum (so I've acchieved "sign in"). My problem, there is no output on the target page (the comment box is on the home page and the target page is in a different group: Guests.GuestList). There is no code on the GuestList page (should there be)? How do I record the author name and time of visit on the GuestList page? http://vintage45s.biz
Brett
I guess you may not have set permission for Fox to post to Guest.GuestList. Put into config.php:
$FoxNameFmt[] = 'Guest.GuestList';
This will allow posting to that specific page. To allow posting to group Guest change it to 'Guest.*'; To allow posting anywhere change to '*.*'. As you have strict edit control on the pages this last one may be fine for you. Fox is just a bit safety cautious in granting authors possibilities to write forms which could post to pages which should not b eposted to. So with simple wildcard characters a pagename "mask" can be created. More examples are in fox.php near the top. HansB
Foxfilters
Is the documentation up-to-date? I got the foxfilters working only after replacing "function MyCustomFilterFunction($fields)" with "function MyCustomFilterFunction($pagename, $fields)". I needed this in the Contact application because contact names often contain umlauts and other special characters (incl '.', ','...). Unprocessed contact names do not work well as filenames -JHJ.
Thanks for pointing this out! I updated the documentation. Yes any foxfilter function needs both $pagename and $fields. HansB
Forum layout
I really like what you’ve done with Fox. I’d like to use it in my site to set up a forum and maybe use it for comments. I’m wondering about how to set it up to make FoxForum look more like a mainstream forum (phpBB and such). I realize what Fox is what some of its limitations are, but I’m curious about a few things.
Thank you for your interest! Please have a look at a new forum prototype I am working on: softflow.co.uk/design/ForumX/ForumX. This is a new Fox-based forum using a page per post (instead of all posts of one topic/thread on one page). More info on the welcome page there. I plan to use some of the features also for the one-page-per-topic FoxForum. HansB
- Can you use PmWiki’s graphical editing buttons with Fox? I’d like to use FoxForum and/or CommentBox but be able to use the various formatting, such as bold and underline. I’d like users to be able to just use PmWiki’s buttons, rather than manually type in the formatting.
Yes. See softflow.co.uk/design/Test/TestCommentBox2. The guibutton markup i use there can work for any textarea input control (multi-line text box). The input markup needs id=text, and then the javascript guibuttons will output into the box. I may release a update on this later.
- How could I change the formatting of FoxForum so that the user’s name is on the side of the post, rather than on top of it? Again, I want the forum to look more like a phpBB forum. Is there a way to have, for example, a frame on the left side of the post with the user’s name and then the actual message in a frame (or whatever method you use in Fox) just to the right of it? In the frame with the user’s name, would it be possible to link to a picture, so that user’s could have a forum icon?
Using Fox this can be done by redesigning the comment template. But be aware of width restraints due to the pmwiki sidebar. I could prototype a template page for this. HansB
- How many forum threads or comments can appear on a page? Is there a way to limit the number of entries and then have the older entries appear on different pages? For example, I set up a FoxForum, but I want to display twenty threads per page, pretty much like other forums. I’m just wondering that if a forum gets very popular that there might be hundreds of threads/comments on a single page. Also, is there a way to alternate the colors of the forum threads on the main page?
For SimpleForum I used BreakPage breakpage2.php for CommentBoxPlus. I still like to adapt it for use with Fox. It is a matter of inserting after every 20 or so posts a breakpage comment marker (invisible). I should get this done soon.
Update: Done now in ForumX. HansB April 11, 2007, at 10:15 AM
- I’d really like to have a blog-like front page and comments for my site. So far, Fox looks like it fits the bill, but I know that PmWiki is supposed to have these functions built into it in the future. Will some of these Fox functions become obsolete when PmWiki includes them automatically? I’m concerned about setting everything up in Fox and then needing to change everything in the (hopefully) near future when PmWiki has this functionality built in.
PmWiki 2.2.0 is not released yet. Fox is based on 2.2.0 beta, and also in beta state. So it is an evolving script, and some bigger changes may be necessary still. That said, I don't think that any future comments capabilities in PmWiki will make Fox dysfunctional. Most likely it will open the door to make some code used in fox simpler. HansB
Watch out for parameter usage mistakes
(:fox pform #top redirect=1 target=Pos.C template=Template.Pos :)
|| '''Pos:'''||(:input text target size=60:) ||
can you see the problem? target is specified twice. This makes Fox silently fail creating new pages. It's an easy mistake to do. SteP
I have not seen a silent page creation failure. There is always a possibility that input controls get identical names. What exactly happens in such cases is not quite clear. Fox provides two ways for setting a number of parameters. So some care is needed. Thanks for the head-up! HansB
One way to get a silent page creation failure: omit both template and templatestring (or set templatestring to ""). The script will eventually redirect to the current page after echoing that a template is mandatory. Technically it isn't silent, practically it is, however, as a user can't really see echoed output.
I think it is correct that Fox returns to the current page if no template could be found. But I plan to have the error echoing changed into a message system. Still using echo to report errors is better than nothing. HansB
Use foxgroup for setting target group
Hans, in the newpageboxplus recipe you have a parameter base=BaseGroup.NewPage that allows setting a base group where NewPage is created. Since Fox can create multiple pages, but newpageboxplus can't, it would be great if Fox supported a base= parameter too, so we could create a list of pages in another group with a single form
(:fox p base=Group target=A,B,C template=Templ.OneForAll:)
would create Group.A, Group.B and Group.C all templated with Templ.OneForAll. SteP
Does foxgroup=Group not work for this? Below is a NewGroupBox.HansB
(:fox box1 #top redirect={$$foxgroup}.A target=A,B,C template=Templ.OneForAll:)
(:input text foxgroup "" size=20:)
(:input submit post "New Group":)
(:foxend box1:)
New Group Box and $FoxNameFmt
I am trying to get a sort of NewGroupBox function using Fox, where it must create the
home page of a new group. But it seems to do, well, nothing useful but create a form:
(:fox npgrp #top redirect=1:)
(:input hidden target value="GTD-Projects-{npg}.HomePage":)
(:input text npg value="Test" size=20:)(:input submit post "New Project Group":)
(:foxtemplate "'''{npg} Project Group'''":)
(:foxend npgrp:)
The form displays correctly, but when I press the button, nothing happens. It works if I create a page without specifying a group. I've also tried setting the foxgroup parameter, but that doesn't help either. Any thoughts? -- rlt, 2007-Mar-28
For creation of new pages in a different group make sure you add a valid pagename pattern to $FoxNameFmt. In your case add something like this to config.php, before including fox.php:
$FoxNameFmt['GTD'] = 'GTD-Projects-*.*';
HansB March 28, 2007, at 10:55 AM
Thank you! That does what I need. -- rlt
Blank pages
Looks really promising, but once I follow the cookbook for the Forum, when I enter a topic and click, I'm directed to a blank page. What should I check for? Thanks.
Make sure you use latest PmWiki 2.2.. -Rene
Problem with PageTextVariables - solved
After updating to the 3/10 release, other recipes where having trouble accessing page text variables. E.g., I have a "commentcontrol" page text variable in a directive:
(:commentcontrol:open:)
With the previous version of Fox I could access this value with PageTextVar and
get the value open. With the 3/10 version of Fox, it is a null string.
If, in the 3/10 version of Fox, I comment out the definition of the page variable $CounterInc, everything works again. What is $CounterInc anyway? I don't see it used in the rest of the recipe,
nor documented. -- rlt, 2007-Mar-13
Sorry that code piece should have not gone into the release! Now removed. I was working on a method of increasing a page text variable value incrementally by one. HansB March 13, 2007, at 09:02 AM
Very cool! The example pages were helpful. Thank you. Pico
Creating page target
I'm busy trying to figure out a way to merge strings given by input fields to create a new "target"-string.
For Example:
[...]
(:input text author size=20:)
(:input text title size=20:)
[...]
How to merge both strings ("author" and "title") to one, which then goes as "target"?
I want to create new pages using Fox (and templates provided by Fox template sites) with nmaes like "[Group].taget", but "target" should be put together out of 2 other strings (e.g. target=author+title)
Someone knows a way to do that? I'm not very familiar with all that...
SimonB
Try this in the fox form (not in the template page): (:input hidden target "{$$Author}{$$Title}":) - HansB
This is now directly supported by Fox, please see the "Field substitutions" portion of the documentation. -- Feral April 13, 2007, at 03:40 PM
Foxtemplate for single line template strings
(:foxtemplate "template string":) works only with very simple templates. I tried:
(:foxtemplate "[=#foxbegin#=]\n{toto} [={[foxdelrange button]}=]\n[=#foxend#=]\n=]":)
and this doesn't work...
Pierre Racine
(:foxtemplate "...":) works only with single line template strings. If you need a multiline template, you need to create a template page with it, and call it via (:fox ... template=MyTemplatePage :) - HansB
Dan Raymond
I get "Call to undefined function UpdatePage() in C:\Program Files\EasyPHP 2.0b1\www\pmwiki\cookbook\fox.php on line 230" any ideas???
You need to update to the latest pmwiki 2.2.0 beta. - HansB
Mike Bishop
Very nice, replaced both comment boxes and forum based on your examples. Some "gotchas" on the Forum
- make sure wikiword spacing is on (1) if you want nice topic displays;
- I added an access code to the forum. This allowed posting to an existing topic, but prevented creation of new topics!
Workaround: Group.Page.php customization that set $EnableAccessCode = false for the index page.
Or add access code to the form which creates a new topic as well. HansB
Yes, of course! It makes little sense to protect additions to a topic but not topic creation [mrb]
Please add new comments/questions at the top of this page!