I need to create a link that point to another website, not to the portal itself trought ajax call. I write this at the moment :
InlineLabel fv1=new InlineLabel("Validator W3C : ");
InlineHyperlink linkfv1 = new InlineHyperlink("HTML" , "http://validator.w3.org/");
InlineLabel fv2=new InlineLabel(" | ");
InlineHyperlink linkfv2 = new InlineHyperlink("CSS" , "http://jigsaw.w3.org/");
but it call the portal. In fact, if i click on HTML it adds #http://validator.w3.org/ in the navigation bar. How can I fix this? Bye
The docs for InlineLabel say that it's meant to be used for "internal" links -- i.e., only to change the part after the #, like you're seeing.
You want to use Anchor -- this will result in an <a> tag being added to your page.
I prefer this solution:
Define an object of HTML class with the necessary parameters then add that object to a container in your GWT interface, FlowPanel for instance.
HTML link = new HTML("Take me to stackoverflow");
flowPanel.add(link);
Related
With setReponsePage, how can I add the page version of the page I want? So for example 3 in http://localhost:8080/wicket-testing/?3.
Thanks.
You need to use #setResponsePage(Page) instead, not #setResponsePage(Class).
First you need to get a reference to the page with that id: session.getPageManager().getPage(pageId).
Are you confusing wicket pages (where the constructor does not need a wicket-id) with panels (where you have to provide a wicket-id)?
setResponsePage itself accepts either a class (with optional PageParameters) or an instance as a parameter:
setResponsePage(DestinationPage.class);
setResponsePage(DestinationPageWithPageParameters.class, new PageParameters().add("id", 42));
setResponsePage(new DestinationPageWithConstructorParameters(param1, param2));
If you are talking about panels (e.g. MyPanel(String wicketId)) then you need to embed this panel into a wicket page because you cannot pass a panel to setReponsePage.
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()')
Using crossrider, is it possible to get link object in a dom and change the link's title.
I am creating a plugin that detect malicious site and add [Malicious] in front of the link.
I probably could do this by parsing strings, but if it is supported by DOM, it would make my life so much easier.
Crossrider extensions support the jQuery ($) object and hence you can use it to obtain your link from within the extension.js file, as follows:
appAPI.ready(function ($) {
// Where <linkSel> is the selector for retrieving the link or links you require
$(<linkSel>).text(); // retrieves the text for the specified <linkSel> object
// OR the following to prefix the link's text with '[Malicious] '
$(<linkSel>).text('[Malicious] ' + $(<linkSel>).text());
});
I've been trying to wrap my head around routing and for that very reason build a small aplication to fiddle around with, but i've managed to stumble upon a problem.
The goal of the whole test was to hide the url 'hostname/content/index/add' and turn it into a url more understandable for a user like 'hostname/wms/content/add'.
But now for some odd reason i cannot redirect using the $this->url() methode. But somehow a normal link like somelink work.
I have build a few routes in the application.ini to test how it works. It's nothing fancy...
resources.router.routes.contentroute.route = "/wms/content"
resources.router.routes.contentroute.defaults.module = content
resources.router.routes.contentroute.defaults.controller = index
resources.router.routes.contentroute.defaults.action = index
resources.router.routes.vacaturesroute.route = "/wms/vacatures"
resources.router.routes.vacaturesroute.defaults.module = vacatures
resources.router.routes.vacaturesroute.defaults.controller = index
resources.router.routes.vacaturesroute.defaults.action = index
So when i type hostname/wms/content i get redirected to the content module's IndexController and it's IndexAction. This works fine for all the links in my views that point to the content module like this
<a href='wms/content/'> link </a>
However it's not working for 3 links that actually redirect towards a specific action of the IndexController on that very page hostname/wms/content.
Add new content
Instead of actually redirecting towards the add action in the IndexController i get redirected to hostname/wms/content, wich is the page i'm comming from.
Anyone have an idea why this is happening and possibly a way to solve this? Or am i totally approaching this the wrong way?
First, your route are static ones. You should replace them with:
resources.router.routes.contentroute.route = "/wms/content/:action/*"
resources.router.routes.contentroute.defaults.module = content
resources.router.routes.contentroute.defaults.controller = index
resources.router.routes.contentroute.defaults.action = index
Then, you should specify the name of your route and pass true in reset argument:
$this->url(
array('module'=>'content', 'controller'=>'index','action'=>'add'),
'contentroute',
true
);
try this instead
Add new content
Replace xyz with your module name.
I have a need to create a <br/> tag in the display label for a menu item generated using Zend_navigation, but don't seem to be able to find a way to do so.
My navigation item is defined in the XML config as:
<registermachine>
<label>Register your Slitter Rewinder</label>
<controller>service</controller>
<action>register</action>
<route>default</route>
</registermachine>
I want to force a tag in the output HTML between 'your' and 'slitter', such that it appears on two line as below:
Register your
Slitter Rewinder
However, I can't seem to do it. obviously using in the XML breaks parsing, and using html entities means that the lable is displayed as:
Register your <br/>Slitter Rewinder
Has anyone had experience of this that can offer advice?
Thanks in advance!
there is no such option built-in you have to use a partial
$partial = array('menu.phtml', 'default');
$this->navigation()->menu()->setPartial($partial);
echo $this->navigation()->menu()->render();
http://framework.zend.com/manual/en/zend.view.helpers.html#zend.view.helpers.initial.navigation.menu
you may also try a hack with <label><![CDATA[Menu label<br/>Second line]]></label>
I found a (hacky) solution:
I updated my navigation.xml to use {br} tokens wherever a <br/> tag is required, and then amended the base Zend/View/Helper/Navigation/Menu.php file as follows:
within htmlify function, changed
$this->view->escape($label)
to
str_replace("{br}", "<br/>", $label)
I could (and probably will) override the Zend Library Menu View Helper with my own at some point, but this at least cover it for now.
there is a escapeLabels boolean used to convert html tags and it's true by default.
You can set your navigation like this
$this->navigation()
->menu()
->escapeLabels(false)
->...
http://framework.zend.com/apidoc/2.0/classes/Zend.View.Helper.Navigation.Menu.html#escapeLabels