<f:link.action> generation in standaloneview adds two underscores (__) - typo3

I'm creating a simple user registration. For that i sent a confirmation mail with hash via the standaloneView and used f:link.action to create the link. It looks as follows.
<f:link.action pluginName="pi1" controller="MyController" action="myAction" arguments="{token: '{token}'}" absolute="true" noCache="true" noCacheHash="true">Confirm</f:link.action>
The created link looks like:
http://www.example.com/mySite/?no_cache=1&tx__pi1%5Btoken%5D=16d5056f209b72422bffa1e6973582190243446f&tx__pi1%5Baction%5D=myAction&tx__pi1%5Bcontroller%5D=myController
My second try was:
<f:link.action pluginName="extKey_pi1" controller="MyController" action="myAction" arguments="{token: '{token}'}" absolute="true" noCache="true" noCacheHash="true">Confirm</f:link.action>
The created link looks like:
http://www.example.com/mySite/?no_cache=1&tx__extKey_pi1%5Btoken%5D=16d5056f209b72422bffa1e6973582190243446f&tx__extKey_pi1%5Baction%5D=myAction&tx__extKey_pi1%5Bcontroller%5D=myController
Here 2 underscores ( __ ) halve been added.
How can i solve this? I can setup an href manually but that isn't very neat.

If you don't create a link within the current extension, you have to provide the extensionName as a parameter as well. Note that you have to pass the name of the extension without underscores.
<f:link.action
extensionName="extKey"
pluginName="pi1"
controller="MyController"
action="myAction"
arguments="{token: '{token}'}"
absolute="true"
noCache="true"
noCacheHash="true"
>
Confirm
</f:link.action>

Related

Adding a confirmation form before the add form of a content type

One of our customers wants to add a terms of service page that has to be shown every time a user adds some specific content type, before the add form.
Any suggestions on how to implement this?
If it's a Dexterity content type, you can do this:
Create a custom form with your terms of service. In the form's button handler, redirect to the add form:
self.request.response.redirect(self.context.absolute_url() + '/++add++name.of.content.type')
Now in your type's factory info in portal_types, set the add_view_expr like this:
<property name="add_view_expr">string:${folder_url}/##terms-of-service</property>
so it goes to the custom TOS form when you click the type in the factory menu, instead of directly to the add form.
(Note: a downside of this approach is that if the user enters the URL of the add form directly, they can bypass the TOS form.)
A possible solution could be to use a cookie/session_data_manager/token/you-name-it that on the custom AddForm for that content type checks if exists.
If it doesn't redirect to that Terms of Service form that redirects back to the Addform where, now it will accept to proceed becuase the cookie/session_data_manager/token/you-name-it will be there.
An idea: when you are adding new content types (AT based content types, this will not work for Dexterity ones) you are calling
http://something/createObject?type_name=Document
You can transform the createObject script into an view that display you disclaimer form, with validation on submit.
When user accept the disclaimer you will redirect the use to something like
http://plone4.gest.unipd.it:8080/gest/it/realCreateObject?type_name=Document
where realCreateObject is a copy/paste of the original Plone createObject script.
However: the suggestion of Mathias above is really good: just add a fake checkbox field with a validation.
As mentioned in the comment of the question. I would advise adding a checkbox to the content.
For AT content you can add a BooleanField
...
atapi.BooleanField(
name='acceptConditions',
schemata='default',
required=False,
default=False,
validators=('acceptConditions', ),
widget=atapi.BooleanWidget(
label=_(u'label_accept_conditions', default='Conditions'),
description=_(
u'help_accept_conditions',
default='Please accept the <a target="_blank" '
'href="./conditions_view">'
'conditions<a/>.')
),
)
...
With a condition on the widget (In this case a browser view, which checks if the boolean field should be visible or not).
YourSchema['acceptConditions'].widget.setCondition(
'python: here.restrictedTraverse("##show_condition_field").show()')

How can I get the anchor (#tag) from an <a> link in tritium?

I am trying to get the anchor tag from an anchor element link in the page eg
<a href="/page#reviews">
Is it possible to access the href so I can isolate #reviews and use it elsewhere in my Tritum script?
Thanks!
Yes, it's possible, using a two step process.
First, you can grab the value of the href attribute using the fetch() function.
Then, working on the isolated string, you can use regular expressions to replace all the characters that occur in front of the hash/pound sign (#) with a blank.
Here's an example using the Tritium Tester: http://tester.tritium.io/52503bcbe166ca7affa4944d90aae39808c8cd8e.
Note: This assumes that everything after the first # sign in the href attribute is what you're looking for.

Change the ID of a standard TYPO3 mailform

Every Form object created in TYPO3 has the ID "mailform".
<form action="thanks/" id="mailform" name="mailform" enctype="multipart/form-data[...]
This seems to be a problem since I have 2 forms on 1 page, and when (I think) the IDs are the same, the validation script doesn't work.
As reported here: http://lists.typo3.org/pipermail/typo3-english/2006-April/024467.html
in your main template setup field add this code:
tt_content.mailform.20.formName >
now every mailform will have a different unique (a hash) form id
Use the form extension (system extension since TYPO3 4.6, see the release notes).
You can define an individual id in the tab Form.
1) Look into the Extension files.. maybe you can change it somewhere there easyily.
2) Is it possible for you to change the id maybe via javascript/jquery?
maybe it helps you fix the problem with the validation script:
$('#mailform').each(function(index,value){
index++;
$(this).attr('id', 'mailform'+index);
});

question about CodeIgniter urls

I am using an application (a blog) written using the CodeIgniter framework and would like to search my blog from my browsers location bar by adding a string to the end of my blogs url like this:
http://mysite.com/blog/index.php/search...
As you can see in the example above I am not really sure how to format the rest of the url after the search part so I am hoping someone here might be able to point me in the right direction.
This is what the form looks like for the search box if that helps at all.
form class="searchform" action="http://mysite.com/blog/index.php/search" method="post">
<input id="searchtext" class="search_input" type="text" value="" name="searchtext">
<input type="submit" value="Search" name="Search">
</form>
Thx,
Mark
Since your form is posting to http://mysite.com/blog/index.php/search, I'm assuming this 'search' controller's default function is the one your are attempting to submit your data to. I think that the easiest way to do this would be to just grab the post data inside of the controller method you're posting to. Example:
function search()
{
$search_params = $this->input->post('search_text');
}
Then you would have whatever the user input stored as $search_params, and you can take actions from there. Am I misunderstanding what you're asking?
It seems like you're kind of discussing two different approaches. If you wanted to make a request to
mysite.com/blog/index.php/search&q=what_I_am_looking_for
This is going to call the search controllers default method (which is index by default). If you wanted to use the URL to pass parameters like that you would go to your function in the search controller and do:
print_r($this->input->get('q'));
This will print out "what_am_I_looking_for".
An easier approach in my opinion would be to:
1. Create a view called "search_view" with the HTML content you pasted above, and have the form "action" http://www.mysite.com/blog/index.php/test/search
Create a controller called "Test" that looks like the following:
class Test extends CI_Controller {
function search()
{
$search = $this->input->post('searchtext');
print_r($search);
}
public function display_search()
{
$this->load->view('search_view');
}
}
Visit http://www.mysite.com/blog/index.php/test/display_search in your browser. This should present you with the form you placed in search_view.php. Once the form is submitted, you should be sent to the search function and print out the variable $search, which will have whatever text you submitted on that form.
If this isn't what you were looking for then I am afraid I do not understand your question.

WIX-based installation results in an invalid configuration file

EDIT
I've decided to try to find a simpler way to ask this question:
If my WIX-based installation needs to modify an XML file that looks like this:
<a>
<b/>
</a>
into one that looks like this:
<a>
<c/>
<b/>
<a/>
Can it be done without a custom action?
Using the XmlConfig element, the closest I can get is this:
<a>
<b/>
<c/>
<a/>
The problem, if I have not made it plain, is that the inserted c element must come before the b element already in the file.
XmlConfig and XmlFile get converted to custom actions btw. Can you start with a different xml file such that you can add all children nodes to the parent in the correct sequence? Otherwise, you can request this behavior as a new feature request to the WiX team here: http://sourceforge.net/tracker/?group_id=105970&atid=642717