How do I fetch the UID of a page that's been selected with flux:wizard.link? - typo3

I'm using the flux:wizard.link to select a page from the page tree in Typo3:
<flux:field.input name="page_id" label="Select page">
<flux:wizard.link activeTab="page"/>
</flux:field.input>
Now, I want to fetch this page and render it in a container.
<v:content.render pageUid="{page_id}" />
But the {page_id} has the t3-link saved instead of the expected pageUID (e.g. t3://page?uid=125)
How do I extract the page's UID?
I could let the user enter just the page-id in an input-field, but I'd rather have her select the page via wizard...

One solution could be to cut the string into two parts:
<v:iterator.explode content="{page_id}" glue="uid=" as="newarray">
{newarray.1}
</v:iterator.explode>
The string page_id is cut at the phrase 'uid=' into two parts, which are saved in the array newarray. With {newarray.1} you can output the second part of the array.
This is most likely not the best solution. It depends on the link which should have always the same structure (containing 'uid=xxx'). But so far it seems to be the only way.

Related

TYPO3 7.6 realURL tx_news Tags configuration

I use TYPO3 7.6.6 with news 4.2.1 and realURL 2.0.14.
I'm using the realURL-Config from the official news-documentation, see below.
I have one detail page for my News (id=33) and my news-tags are listed in folder id=32
...
'fixedPostVars' => array (
...
'33' => 'newsDetailConfiguration',
'14' => 'newsTagConfiguration' // must be the list view for news records
...
The links from the news-list to detail page are working perfect (http://www.example.com/profi-guides/news/detail/some-text/), but I also show the tags, and if the user click, I've got a link like this:
http://www.example.com/news/detail/?tx_news_pi1%5BoverwriteDemand%5D%5Btags%5D=11&cHash=40c263fd16c0e3a3c548c952f1d6b1da
This is my FLUID-Snippet in the News-List-View:
<f:if condition="{newsItem.tags}">
<!-- Tags -->
<div class="tags">
<i class="icon-icon-tag"></i>
<f:for each="{newsItem.tags}" as="tag">
<f:link.page title="{tag.title}" class="active" pageUid="{settings.listPid}" additionalParams="{tx_news_pi1:{overwriteDemand:{tags: tag}}}">
<span>{tag.title}</span>
</f:link.page>
</f:for>
</div>
</f:if>
How do I get clean realURL-Links from news tags?
My Goal: Listview of news records. If the user click a tag below every news-record -> list view show all news with the corresponding tag. This works already. Only the Link/Querystring is the problem, I need nice URLs, and nothing like ..?tx_news_pi1%5BoverwriteDemand%5D%5Btags%5D=11&cHash=40c263fd16c0e3a3c548c952f1‌​d6b
My news-list plugin is at uid14, the detail-view at uid33, my news records at uid31and my news tags at uid33.
The solution: realURL Config : newsTagConfigurationhas to be the uid from list view, not from the folder, where the tags are included.
The point to show each news with the tag, so you have a small misconfiguration because of your folder ID.
The documentation says:
"The configuration of newsDetailConfiguration is used for the single
view. Its name is not that important but the same name has to be used
in line 86 where the uid of the single view page is set. In this
example it is 70. Of course you need to set the uid of your single
view page."
I think the solution is simple, you need a single view to your tags just like for the categories and not the folder, where your records are collected.
You can not open a tag inside a folder but you need a page with a plugin to handle that.
See the "Tag List" in the documentation from news here.
Tag list
Use this action to show a list of tags.
If you define a specific page id in field "PageId for list display"
(inside the tab "Additional") and placing a news plugin with the type
"List" there, it is possible to create a tag filter.
UPDATED from the comments:
Try to change the ID to your news List page ID. You have a page for list it is X you have a detail it is 33 and a Folder it is 32. So you have to change 32 to X. See your fluid you have there a part in the link.page: pageUid="{settings.listPid}" listPid is the value, what needed to be used for the Taglist config as well.

Best way to declare content element uids to use them in fluid templates

I want to display some contentlement on every page with fluid templates. My solution was to create a typoscript element like:
lib.my.myelement= CONTENT
lib.my.myelement {
table = tt_content
select {
pidInList = 15
where = uid=99
}
}
and then use it in the fluid template with:
<f:cObject typoscriptObjectPath="lib.my.myelement" />
Another way is to create them directly in fluid with v:content.render or v:content.get. In this example I get all content elements on one page and save them in an array:
<v:variable.set name="contentElements" value="{v:content.get(column:'0', limit:'3', pageUid:'9', render:'FALSE')}" />
I can not use the first solution, cause on this page there will be much different languages ( I could use it, but every time a new language is added I would have work to declare all new uids of the new elements in typoscript).
The second solution would work better, cause when you translate a page the element uids change, but the pageUid does not change. But here I have the problem that I don't just need all elements, I also have to identify each element.
Here is how I use the second solution:
<v:variable.set name="contentElements" value="{v:content.get(column:'0', limit:'3', pageUid:'9', render:'FALSE')}" />
<f:for each="{contentElements}" as="contentElement" iteration="footerIteration">
<div class="column{v:math.sum(a: footerIteration.index, b: 1)}">
<v:content.render contentUids="{0:contentElement.uid}" />
</div>
</f:for>
As you can see, I use every element the same way.
lets create a simple case:
I have a page with the pageUid = 10 (this page will have translations). On every of this translations will be 3 elements. Lets say 1 element got the "id" (with id I mean something how I can identify this element) title1 and the other two elements have the id list1 and list2.
And my question now is How could I access for example list1?
I hope its understandable, if something is not clear please leave a comment.
Edit: I could use the same order on every translation for the elements and then check the iteration in the for-loop (see the second solution) to identify them. But I wonder if there a better, cleaner way.

CQ Dialog: Possible to provide placeholder in text?

We have a requirement wherein a section of a page will be part authorable and part dynamic. What I mean by this is "You have 6 visits left out of 16." The 6 and 16 in the sentence are coming from a REST service call but the text "You have...visits left out of.." has to be authorable through dialog. Also, we are using AEM 6.
Thanks in advance
Maybe this solution will help others looking for simple placeholder text for their dialog textfields (OP not so much). Use an emptyText attribute...
<dialogText fieldLabel="AEM CLassic UI Text" jcr:primaryType="cq:Widget"
name="./nameOfText" emptyText="THIS IS THE PLACEHOLDER" xtype="textfield"/>
Perhaps you can start by extending foundation/components/text, where the user would be expected to enter a valid formatable string (i.e. "You have %d visits left out of %d").
In your component you would be implementing text.jsp therefore overriding the default behavior of foundation/components/text, in which you can do something like
<cq:text property="text" escapeXml="true"
placeholder="<%= Placeholder.getDefaultPlaceholder(slingRequest, component, null)%>"
tagName="span"
tagClass="myformatedmessage" />
You use tagName and tagClass which will wind up putting the formattable text in a <span class="myformatedmessage">...</span>. Then use jQuery to find it and populate the format placeholders after getting the data via ajax. All that jQuery code you can probably put into a clientlib folder within the same component you extended.
Based on your description, I think you are looking for replacement or substitution instead of placeholders.
"placeholder" generally refers to display text inside a form input that is displayed until the user enters data in the field (such as hint data).
You generally have 3 options for replacing parts of the data:
Server-side (prevents page from being cacheable in dispatcher). Requires parsing authored content & replace some kind of tags with desired REST data, such as "You have ${x} visits left out of ${y} total". Other ways of "tagging" substitution data could look like "You have %x% visits left out of %y%"
client-side JavaScript DOM manipulation once REST data returns. ie $el.html(newDomContentString)
client-side JavaScript templates (handlebars, dust, etc). Takes more initial setup in JS, but generally scales better.

How to select and store ContentElement UID in Flux FlexForm Configuration?

I'm currently building a TYPO3 PageTemplate with Flux and Fluidpages (both GitHub Master-Branch).
I'd like to have the possibility to select a number of ContentElements from the PageTree and store the UIDs in a variable for later rendering.
My first approach combining a Flux TreeField with a RelationField:
<flux:form.sheet name="content" label="content settings">
<flux:field.tree
name="treetest"
label="treetest"
table="pages"
parentField="pid"
foreignLabel="title"
multiple="true"
minItems="0"
maxItems="1000"
size="8"
expandAll="false"
/>
<flux:field.relation
name="relationtest"
label="relationtest"
table="tt_content"
condition="AND tt_content.pid IN ({treetest})"
multiple="true"
size="8"
minItems="0"
maxItems="3"
/>
</flux:form.sheet>
This sadly results in a SQL-Error because the last condition is inserted as:
AND tt_content.pid IN (60|foo)
Where 'foo' is the title of a SysFolder with the UID 60.
Debug-Output in the frontend prints the field 'treetest' as:
treetest => '60' (2 chars)
and the condition for the field 'relationtest' as:
condition => 'AND tt_content.pid IN (60)' (26 chars)
Questions:
As a matter of fact, I'm missing something here and I'd appreciate any hint, where the crux is here?
Is there maybe a different solution to select a ContentElement from the PageTree?
1) It is possible that you have either a default value, an inherited value or somehow disconnected XML which contains the other value. To be 100% sure none of these are your cause, try the same on a completely new page. The expected result of your code and selecting a page UID, is exactly the value 60 - nothing more, nothing less.
2) You may find it easier to use a ###STORAGE_PID### marker in your foreign_table_where and selecting the page(s) allowed for content selection, as values in the Behavior tab when editing your content element or page. This value has the added benefit of being possible to allow only for certain users or usergroups, or admins only.

xpath query question

below is my xml document and right now my query is: /description/*/text(), I can get all the text except that the text inside the <strong> lunch </strong> which "lunch" doesn't display.
This is probably a simple fix but I just couldn't get it correct.
<description>
<![CDATA[
<p>
Envie is a brand new Bar Lounge that offers a modern-design space opening onto Wyndham Street, where on busy nights the crowd spills out onto the street...
</p>
<p>
If you are in for a <strong>lunch</strong>, the Twangoo voucher will offer you two delicious Lunches – perfect for that lunch meeting, a casual date or just a get together with friends in a relaxed and modern atmosphere.
</p> ]]>
</description>
Try
/description//text()
Right now you are selecting every text only for all the child nodes of description.
If you use //text() instead; you are selecting every text for all nodes that are descendant of the current node (description).
Your query /description/*/text() selects the text node children of the element children of the description element. But the description element has no element children. It would have, except that the CDATA is telling the parser not to treat the <p>...</p> content as markup, but as plain text. I don't know why the XML is wrapping this stuff in CDATA, but it makes it much harder to process it or query it.