Sulu: How to display single_select as select instead of radio input? - sulu

is there a way to display a single_select in sulu admin as select box instead of a radio input?
I have a definition like this:
<property name="imagePosition" type="single_select" colspan="6">
<params>
<param name="values" type="collection">
<param name="left">
<meta>
<title lang="en">Left</title>
</meta>
</param>
<param name="right">
<meta>
<title lang="en">Right</title>
</meta>
</param>
<param name="top">
<meta>
<title lang="en">Top</title>
</meta>
</param>
<param name="bottom">
<meta>
<title lang="en">Bottom</title>
</meta>
</param>
<param name="afterHeadline">
<meta>
<title lang="en">After Headline</title>
</meta>
</param>
</param>
</params>
</property>
Maybe something like <param name="values" type="collection" input="select">?
Thx a lot!
Andreas

You can create you custom template for rendering single_select type and specify this template in SuluContentBundle configuration
sulu_content:
types:
single_select:
template: 'AppBundle:admin:single_select.html.twig'
More detailed instruction: Display single_select as select instead of radio input on Sulu admin

That is not implemented yet... So I am afraid to say that this is not working :-/

Related

Symfony ~ SULU - Property from "route" to "resource_locator"

In the exemple i made in the pictures, i change the property "url" of "Mathématique" page type from "route" type to "resource_locator" but this one is skipped in the hierarchy usage.
Do you have any idea about how to refresh URLs ?
<property name="url" type="resource_locator" mandatory="true">
<meta>
<title lang="en">Resourcelocator</title>
<title lang="de">Adresse</title>
</meta>
<tag name="sulu.rlp"/>
</property>

Sulu as a Pagebuilder: block within block

I want to use sulu as a pagebuilder.
A have a block with multiple elements in it. Now my next goal is to provide fields to sho a "Accordion-Script".
The Elements consist of
title (text_line)
content (text_editor)
I hoped that i could use a block in an other block like so:
<block name="contents"
default-type="editor"
minOccurs="0"
maxOccurs="200"
mandatory="true">
<meta>
<title lang="de">Artikelinhalt</title>
<title lang="en">Contents</title>
</meta>
<types>
<type name="tabs">
<meta>
<title lang="de">Tabs</title>
<title lang="en">Tabs</title>
</meta>
<properties>
<block name="tabContents"
default-type="editor"
minOccurs="0"
maxOccurs="200"
mandatory="true">
<types>
<type name="tabContent">
<meta>
<title lang="de">Texteditor</title>
<title lang="en">Text editor</title>
</meta>
<properties>
<property name="article" type="text_editor">
<meta>
<title lang="de">Inhalt</title>
<title lang="en">Content</title>
</meta>
<params>
<param name="table" value="true"/>
<param name="link" value="true"/>
<param name="paste_from_word" value="true"/>
<param name="height" value="400"/>
<param name="max_height" value="2000"/>
<!-- CKEditor Parameters examples: -->
<param name="extra_allowed_content" value="img(*)[*]; span(*)[*]; div(*)[*]; iframe(*)[*]; script(*)[*]" />
</params>
</property>
</properties>
</type>
</types>
</block>
</properties>
</type>
[...] here are my other type-attributes.
It does not work (backend is not loading the edit-page at all).
Is there a way to do that?
The Page should later be editable by the user and could have a structure like that:
- block
- text
- accordion
- text
- text
- text
- image
With Sulu 2.1.0 nested block support has been added to the core, see the release notes here https://sulu.io/blog/sulu-release-2-1-0-2-0-9
There is no support of nesting blocks in Sulu, but if I have a look at your example I would also say that it is not necessary to have nested blocks here.
It looks like you just want to group these blocks, therefore you could simply use a section:
<section name="contents">
<meta>
<title lang="de">Artikelinhalt</title>
<title lang="en">Contents</title>
</meta>
<properties>
<block name="tabContents"
default-type="editor"
minOccurs="0"
maxOccurs="200"
mandatory="true">
<types>
<type name="tabContent">
<meta>
<title lang="de">Texteditor</title>
<title lang="en">Text editor</title>
</meta>
<properties>
<property name="article" type="text_editor">
<meta>
<title lang="de">Inhalt</title>
<title lang="en">Content</title>
</meta>
<params>
<param name="table" value="true"/>
<param name="link" value="true"/>
<param name="paste_from_word" value="true"/>
<param name="height" value="400"/>
<param name="max_height" value="2000"/>
<!-- CKEditor Parameters examples: -->
<param name="extra_allowed_content"
value="img(*)[*]; span(*)[*]; div(*)[*]; iframe(*)[*]; script(*)[*]"/>
</params>
</property>
</properties>
</type>
</types>
</block>
</properties>
The sections are a pure visual help for the content manager, and won't have any effect on the structure passed to the twig template.

Sulu Cmf: Relations as Select/Multi-Select

Is there a way to define Relations (embed an entity) from an other type?
For example i have BlogPost and i have (already existing) other BlogPosts.
I want to have a Multi-Select to define related BlogPosts.
I didn't find it in the docs.
How can i accomplish this?
i guess smartcontent should do it.
could be defined in your template like:
<property name="pages" type="smart_content">
<meta>
<title lang="en">Smart Content</title>
</meta>
<params>
<param name="properties" type="collection">
<param name="title" value="title"/>
<param name="description" value="excerpt.description"/>
</param>
<param name="present_as" type="collection">
<param name="one">
<meta>
<title lang="en">One column</title>
</meta>
</param>
<param name="two">
<meta>
<title lang="en">Two column</title>
</meta>
</param>
</param>
</params>
</property>
also see the documentation:
http://docs.sulu.io/en/latest/book/creating-a-basic-website/using-smart-content.html

Default route is matched instead specific route

<routes>
<www type="Zend_Controller_Router_Route_Hostname">
<route>www.domain.com</route>
<chains>
<index type="Zend_Controller_Router_Route">
<route></route>
<defaults module="default" controller="index" action="index" />
</index>
<community>
<route>community</route>
<defaults module="community" />
<chains>
<index type="Zend_Controller_Router_Route">
<route>:action/*</route>
<defaults controller="index" action="index" />
</index>
<member type="Zend_Controller_Router_Route_Regex">
<route>member/profile-(\d+)-(.+)</route>
<reverse>member/profile-%d-%s</reverse>
<map>
<id>1</id>
<nom>2</nom>
</map>
<defaults action="viewmember" />
</member>
</chains>
</community>
</chains>
</www>
As you can see, I use a route with :action/* in to cover the homepages and the basics actions on index controller.
domain.com/community/random_action => works good.
domain.com/community/ doesn't work. The whole homepage is displayed.
I checked, and the default route is matched.
I tried assemble() on route "www-community-index" and it gives well www.domain.com/community
I don't see from where comes the problem :(
The first thing you should check is if you deleted the default route.
The second one is....remember that the routes are checked in reverse order. This means that the most specific should be the first and the default the last one.

Redirect to default action in Struts 2

I have an action with an empty string for name defined in the root namespace, and I want to redirect to that action from another action if a certain result is found, but it doesn't seem to work.
Here's the default action
<action name="" class="com.example.actions.HomeAction">
<result name="success" type="freemarker">freemarker/home.ftl</result>
</action>
And I'm defining the redirect in the global-results for the package:
<global-results>
<result name="sendToRouting" type="redirectAction">
<param name="actionName"></param>
<param name="namespace">/</param>
</result>
</global-results>
I've tried taking out the actionName parameter, but that doesn't work. If I put a name in for the HomeAction and reference it by name in the global-results it works, so I'm assuming the problem is lack of action name for the redirect.
Any thoughts?
I think that what you want to do is use <default-action-ref />:
<package name="home" namespace="/" extends="struts-default">
<default-action-ref name="home" />
<action name="home" class="com.example.actions.HomeAction">
<result name="success" type="freemarker">freemarker/home.ftl</result>
</action>
</package>
Sorry...misread the question:
Try changing type="redirectAction" to type="redirect", I'm fairly sure that redirectAction is now redirect.
Were you getting a NullPointerException because the actionName parameter is blank? I hacked around this by providing a string which evaluates to an empty string:
<param name="actionName">${}</param>
Still looking for a more "correct" solution though...