TYPO3 - url selector after input field in flexform - typo3

I have seen extension with flexform where an input field is for entering an URL (example: gkh_rss_import). After the input field there is an URL selector. When pressing it the default TYPO3 selection pops up with URL to internal page, external, image etc.
But in the xml for the flexform I see only the code for a normal input field, not an URL selector.
So I guess the URL selector somehow is added outside the flexform xml. But how?

This is done through an additional <wizards> node for the input element in FlexForm XML:
<config>
<type>input</type>
<eval>trim</eval>
<size>60</size>
<default></default>
<wizards type="array">
<_PADDING type="integer">2</_PADDING>
<link type="array">
<type>popup</type>
<title>Link</title>
<icon>link_popup.gif</icon>
<script>browse_links.php?mode=wizard</script>
<JSopenParams>height=500,width=500,status=0,menubar=0,scrollbars=1</JSopenParams>
</link>
</wizards>
</config>
You can find details about the available wizards and their configuration options in doc_core_tca, section "Additional $TCA features" (under headline "browse_links.php"). This is all about PHP arrays, but FlexForm XML is just another way to store the same configuration data.
Cheers, Jörg.

Related

Specify sitemap language (same language for all sitemap)

According to Google, you can specify languages in a sitemap like this:
<url>
<loc>http://www.example.com/english/page.html</loc>
<xhtml:link
rel="alternate"
hreflang="de"
href="http://www.example.com/deutsch/page.html"/>
<xhtml:link
rel="alternate"
hreflang="en"
href="http://www.example.com/english/page.html"/>
</url>
However, I just need to specify that ALL the sitemap/website is in Spanish, which means it's not a multi-language sitemap, it's a one-language sitemap but that language happens to be "Spanish".
Should I include a hreflang tag for each and every URL? or is there a better way to do this, like specifying it in the header section?
No, setting header for the sitemap xml only sets it for the sitemap.xml and not all locations declared in the sitemap. You have to declare it for all locations.
Checked with the URL inspection tool to see if there are any errors with Google trying to index your site.
If you had access to the server, you can set Link response header alongst the following lines.
Nginx
add-header Link <$scheme://$host$request_uri>; rel="alternate"; hreflang="es"
Apache
Header set Link "<%{REQUEST_SCHEME}://%{HTTP_HOST}%{REQUEST_URI}>; rel=\"alternate\"; hreflang=\"es\""
Also, you could set the "lang" attribute on the "html" tag or "link" tag of every page in your website. You can use a template for this if your site is built using a static site generator.
If you only have access in Cloud console, you have to make an entry for every location in your website in the sitemap.xml.

Call tx_blog viewhelper from other extension

I'm using the Typo3 blog extension (tx_blog) for my website. In the blog template the link for the category overview comes from the viewhelper blog:link.category. It creates a nice URI without query parameters or chash (/blog/category/flowers) as configured.
I now need to create a link to the same category page from a template from another extension. Using the same viewhelper gives me the above uri but it adds the controller and action from my own extension as query parameters.
So I copied the viewhelper and changed the urifor call to pass on the values of the blog extension. The action when set to NULL is gone, but the controller is still added. Also the chash parameter is still there.
How can I get the right URI from a different extension context?
You can use any ViewHelper installed in the system by registering it in the template head.
Example:
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" xmlns:v="http://typo3.org/ns/Vendor/ExtensionKey/ViewHelpers" data-namespace-typo3-fluid="true">
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" means that the namespace f can be used for the default TYPO3 ViewHelpers.
xmlns:v="http://typo3.org/ns/Vendor/ExtensionKey/ViewHelpers" is a registration of all ViewHelpers of the Extension Vendor/ExtensionKey, which can be used in the template with the namespace v.
data-namespace-typo3-fluid="true" means that the <html> element won't be in the output.

cq include not working, 404 error

I tried to include a component in another component using following code
<%
String fakePath = resource.getPath() + "/nav-tabs";
%>
<cq:include path="<%=fakePath%>" resourceType="ven/components/navMenu"/>
When I open the site page and tried to edit the component to author data, following error is coming in the browser console and not able to see the component dialog.
widgets.js:3318 GET
http://localhost:4502/content/ven/global/en/testPage/jcr:content/nav-tabs.infinity.json?_dc=1481236797569
404 (Not Found)
I do not see any resource created below the content tree too.
Could any one shed some light on this?
Thanks,
Sri
It looks like you placing this component directly on the page, because resource.getPath() returns http://localhost:4502/content/ven/global/en/testPage/jcr:content in your case. You can use page templates to create initial content when creating the page.
For components you can use cq:template resource:
Just place cq:template resource beneath your component. As soon you add a new component it should copy the content of it into your resource (similar to page templates)
In your case: _cq_template.xml :
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
jcr:primaryType="nt:unstructured">
<nav-tabs
jcr:primaryType="nt:unstructured"
sling:resourceType="ven/components/navMenu"/>
</jcr:root>

Fluxfield for internal Link with pagetree

How can I create a fluxfield to create a link to another page, where the user can chose the page in a pagetree. Something like the Modify Linkfrom the RTE. Is there something?
Or how else would I create a field for a internal link? Just an inputfield where the use can input the PageID is not enough.
One more step would be a field where the user can input an internal link OR an external link.
Have not found any good solution for this problem yet. How do you do it?
You can use a normal text input, but add a link wizard to it. Looks like this:
<flux:field.input
name="link"
label="Link!"
>
<flux:wizard.link/>
</flux:field.input>
To output the link, use one of the ViewHelpers v:(link|uri).typolink from EXT:vhs:
<v:link.typolink configuration="{parameter: link}">
Linktext
</v:link.typolink>
This works for all kinds of links.

How to display Link to Page fields properly in Liferay Dynamic Data Lists?

The context
I am trying to create a link list portlet on a page in my Liferay 6.2 instance. To achieve this, I have put a new Dynamic Data List Display portlet on the page and made a Data Definition that contains a Link to Page (it used to be called Link to Layout before 6.2) field. I am trying to build a custom Display Template using Liferay's guide to display an HTML unordered list with the links, but I cannot find any information regarding how to handle Link to Page field properly.
The question
How can I create a Freemarker template that displays the Link to Page field so that the href attribute contains the smart url of the page and the link text is the localized name of the page?
The Display Template editor adds the following code to the Freemarker script when you click your field:
<a href="${ddmUtil.getDisplayFieldValue(themeDisplay, cur_record.getFieldValue("Link_to_Page1632", locale), cur_record.getFieldType("Link_to_Page1632"))}">
Link to Page
</a>
This is a good hint to start displaying the links, just add the small details:
<#-- The record service to retrieve the list of records in this Dynamic Data List -->
<#assign DDLRecordLocalService = serviceLocator.findService("com.liferay.portlet.dynamicdatalists.service.DDLRecordLocalService")>
<#-- The layout service that helps determine the name of the page -->
<#assign layoutService = serviceLocator.findService("com.liferay.portal.service.LayoutService")>
<#-- Get the records in the Dynamic Data List -->
<#assign records = DDLRecordLocalService.getRecords(reserved_record_set_id)>
<ul>
<#if records?has_content>
<#list records as cur_record>
<li>
<#-- Use the snippet provided by the editor -->
<a href="${ddmUtil.getDisplayFieldValue(themeDisplay, cur_record.getFieldValue("Link_to_Page1632", locale), cur_record.getFieldType("Link_to_Page1632"))}">
<#-- Get the name of the page with layoutService.getLayoutName() using a temporary JSON object -->
<#assign jsonObj = jsonFactoryUtil.createJSONObject(cur_record.getFieldValue("Link_to_Page1632"))>
${layoutService.getLayoutName(jsonObj.getLong("groupId"), jsonObj.getBoolean("privateLayout"), jsonObj.getLong("layoutId"), localeUtil.toLanguageId(locale))}
</a>
</li>
</#list>
</#if>
</ul>