.properties storing long text values/lists/other - jsf

I am in the process of internationalising a website and I can't seem to find a way to store large paragraphs that my contain some other tags.
For example let's say I have this : (call this example 1)
<h1> the title </h1>
<p>
... A very large paragraph ... <h:link value="click me" outocme="newPage"/> ... more text...
</p>
Or again something of this sort : (call this example 2)
<h1> check this list out </h1>
<ul>
<li> ... text here </li>
<li> ... text here </li>
<!-- more items -->
</ul>
I am in JSF 2.0 and using the bundeled resource to internationalise my page and that's working fine as there are many examples how to do this.
But what I'd like to be able to do is something like this for example 1 (msg being my variable linked to my bundle)
<h1> #{msg['page.title']} </h1>
<p> #{msg['page.largeParagraph']} </p>
And example 2 would look like this :
<h1> #{msg['page2.title']} </h1>
<ul>
#{msg['page2.myList']}
</ul>
Is there any way to do that, or do I have to resort to something like this (using example 1)
<h1> #{msg['page.title']} </h1>
<p>
#{msg['page.largeParagraph.part1']} <h:link value="#{msg['page.largeParagraph.link']} #{msg['page.largeParagraph.part2']}
</p>
The same would be for example 2 where I would need a different entry for each <li>.
What is the best practice when we are doing something of this sort?
Thank you for any input.
Edit :
It had occured to me that by default did escape characters. Therefore I have tried :
<p><h:outputText value="#{msg['page.paragraphWithLink']}" escape="false"/></p>
Unfortunately, this did not work for me.
Edit 2 :
Using escape="false" did work for <strong> but definetly does not work for <h:link>.

You cannot specify JSF components in the bundle file. They won't be parsed as part of the component tree. The webbrowser also doesn't understand JSF tags, it only understands HTML. Just plain HTML should work with <h:outputText escape="false">.
page.paragraphWithLink=lorem ipsum click me dolor sit amet

Related

Liferay 7.3: How can I use custom ADTs in a page template?

I want to have ready components for a page, when a page template is used. E.g. when I create a page using subpage-1 template, it'd give a place to drop a banner image (or leave a template image) and add breadcrumbs automatically (no need to customise).
They both have custom ADT, which I can't seem to find from the Page Template options. (It seems to have it's own "site" in the admin bar, when editing the template, so my guess is it doesn't find anything from my main site.)
Is there a way to get the custom ADTs for the page template? For clearance, the route to the template is Site Builder --> Page Templates --> New Collection --> New page template.
Possible workaround?
This is my subpage-1-column.ftl code, which has two dropping places: One for the banner image and breadcrumbs (which I would like to have automatically placed) and the other for the other stuff. Is it possible to add all the things here, that I want my page template to do (content place, type, adt...)?
<div id="main-content" class="container-fluid subpage-1-column">
<div class="portlet-layout row no-gutters">
<div class="portlet-column portlet-column-only col-12" id="column-1">
${processor.processColumn("column-1", "portlet-column-content portlet-column-content-only")}
</div>
</div>
<div class="portlet-layout row no-gutters">
<div class="portlet-column portlet-column-only col-12" id="column-2">
${processor.processColumn("column-2", "portlet-column-content portlet-column-content-only")}
</div>
</div>
</div>
Promoting a comment to answer:
ADTs can live in global scope, there they're independent of a "current site".
Downside: Global means global and comes with the general downside of anything global. In this case, I believe that it's not much of a problem, but you'll have to validate that for yourself.
My recommendation is to look at Content Pages / Master Pages though, as they're a lot easier to edit than Freemarker Templates.
In your comment you say that Master Pages "destroy" your footer, header etc, which they're not supposed to do and I wonder about the root cause there. But anyway: You seem to have your ADT already, and global scope seems to fix your issue. I'll leave it at that. Going after the Master Page issue's root cause would be a different question (but might no longer be programming related)
If you're looking for a code template for the possible "workaround":
<div id="main-content" class="container-fluid subpage-1-column">
<div class="portlet-layout row no-gutters">
<div class="portlet-column portlet-column-only col-12" id="column-1">
${processor.processColumn("column-1", "portlet-column-content portlet-column-content-only")}
<#assign portletPreferences = { "displayStyle" : "ddmTemplate_ADT_CUSTOM", "portletSetupPortletDecoratorId": "borderless", "headerType" : "none", "delta" : "10", "paginationType" : "none" } />
${processor.processPortlet("com_liferay_asset_publisher_web_portlet_AssetPublisherPortlet", portletPreferences)}
</div>
</div>
<div class="portlet-layout row no-gutters">
<div class="portlet-column portlet-column-only col-12" id="column-2">
${processor.processColumn("column-2", "portlet-column-content portlet-column-content-only")}
</div>
</div>
</div>
This will add an AssetPublisher to your first column with a specific ADT (ddmTemplateKey = ADT_CUSTOM)
To see all available portletPreferences check your database or copy the following code in one of your ADTs:
<#list portletPreferences?keys as prop >
<li>
${prop}
</li>
</#list>

How to get href attribute using selenium for python?

I want to get the href attributes from the given HTML code so that i can go inside the link and scrape some data from it.
<div class="cb-col cb-col-67 cb-rank-plyr"> <a class="text-hvr-underline text-bold cb-font-16" href="/profiles/1643/aaron-finch" title="Aaron Finch's Profile">Aaron Finch</a> <div class="cb-font-12 text-gray">AUSTRALIA</div> </div>
<div class="cb-col cb-col-67 cb-rank-plyr"> <a class="text-hvr-underline text-bold cb-font-16" href="/profiles/10863/fakhar-zaman" title="Fakhar Zaman's Profile">Fakhar Zaman</a> <div class="cb-font-12 text-gray">PAKISTAN</div> </div>
I want to get the attributes of href and save it to a list.
You can use regular expressions to parse out thinks in the HTML such as that href tag.
Here is an article explaining that: https://medium.com/#tracy_blog/regex-and-selenium-2c5a89f23a17
To accomplish this, I would consider using get_attribute(name) over a regular expression.

XPages "xsp://" in rich text - what is that protocol?

I am using code I found in the sanple database that comes with the book "Mastering XPages, 2nd edition" - Chapter 11, that has a managed bean to handle the rich text.
in there, it converts html links to xsp:// links. Anyone knows what they are and how they work?
This is a sample HTML output generated by this bean, for two attachments and an Embedded image:
<p dir="ltr"><a class="xsp-inline-attachment application-vnd-openxmlformats-officedocument-spreadsheetml-sheet" href="xsp://Docum2.1.xlsx">Docum2.1.xlsx</a></p>
<p dir="ltr"> </p>
<p dir="ltr"><a class="xsp-inline-attachment application-vnd-openxmlformats-officedocument-wordprocessingml-document" href="xsp://CM034468.docx">CM034468.docx</a></p>
<p dir="ltr"> </p>
<p dir="ltr"><img src=cid:blue_lava_lamp_md_wht /></p>
I'd like to understand a bit better how this all works, as we have "invalid persisted content session id" issues that pop up often...
Thanks a bunch

how to make custom templates in Koken

I'm using Koken and would like to customize the template for text entries by putting the date at the top of the entry.
I hacked a call to new Date() into the core template file /admin/templates/text.tmpl.html
<div id="entry-editor">
<div id="edit-area" data-bind="html: content() ||
'<p class=\'date\'>' + new Date() + '</p>
<p class=\'media-row\'><br /></p>'">
</div>
</div> <!-- close #entry-editor -->
This works fine, but I know the perils of hacking core files.
As of this writing, I don't see an answer on the page linked as "define your own custom template types" on help.koken.me.
Without hacking core files, how can I have Koken add a date to the top of each text entry?
From http://help.koken.me/customer/portal/questions/1080677-how-to-make-custom-templates-in-koken-
Simply place a <koken:time> tag in the customized theme template.
For example, in my /storage/themes/<custom-theme-name>/essay.lens file:
<header>
<h2>
<koken:link>{{ essay.title }}</koken:link>
</h2>
<p>
<strong><koken:time show="time" /> <koken:time show="date" /></strong>
</p>
</header>

expression engine: Content in channel fields don't show up on the webpage when called in a template

I have a snippet called sidebar with the following code.
<div id="ebook_offer">
{exp:channel:entries channel="test"}
<h3>Ebook</h3>
{/exp:channel:entries}
</div>
<div id="about_blog">
{exp:channel:entries channel="blog_sidebar"}
<h3>About Obsia's Blog</h3>
{/exp:channel:entries}
</div>
<div id="testimonials">
</div>
<div id="demo" dynamic="no" limit="1">
</div>
<div id="recent posts">
{exp:channel:entries channel="blog" limit=5 offset=1}
<h3>Recent Posts</h3>
<li>{title}</li>
{/exp:channel:entries}
</div>
<div "connect">
</div>
<div = "subscribe">
{exp:mailinglist:form list="blog_list" form_id="blog_subscribe"}
<h3>Subscribe</h3>
<p>First Name <input type="text" name="first_name"="{first_name}"></p>
<p>Email <input type="text" name="email" value="{email}"></p>
<p><input type="submit" value="submit"></p>
{/exp:mailinglist:form}
</div>
This snippet is called inside the index.php template for blog template group and the code is as follows:
<div id="blog_display">
{exp:channel:entries channel="blog" limit="5"}
<h2>{title}</h2>
{author}
{if blog_images} <img src="{blog_images}" alt="blog image {title}" class="some_class" />
{/if}
{teaser}
<p>comments {comment_total} </p>
{/exp:channel:entries}
</div>
{sidebar}
I also have channel called sidebar with fields such as ebook_offer, about_blog, recast posts, testimonials, subscribe. I can get the subscribe forms to show up. I can see recent posts on my webpage but can't see any of the content that has been filled in about_blog field.
Anyone know why blog channel works but not my sidebar channel.
I'm not quite sure what the problem is exactly without having all of your code in front of me, but it could be a few things. For starters, if your blog homepage template has an {exp:channel:entries} tag in it, and you're including the snippet inside of that tag, you'd run into problems. You can't nest an {exp:channel:entries} inside of another.
Also, channel entry tags are set to dynamic by default. They will look at the URL for hints about what entries to pull from the database. Try adding the dynamic="no" parameter to your sidebar entries tag, which you can learn more about here. This should make the tag ignore the page's URL, which is what you want. You might also want to add the limit="1" parameter to that tag as well, to ensure that only one sidebar entry is being rendered.
Please let me know if neither of those answers help!
The best strategy would be to move what's in your snippet into a separate template file while you try to figure this out. I noticed a couple of things that seem off to me in your sidebar snippet code.
<div id="ebook_offer">
{exp:channel:entries channel="test"}
<h3>Ebook</h3>
{/exp:channel:entries}
</div>
<div id="about_blog">
{exp:channel:entries channel="blog_sidebar"}
<h3>About Obsia's Blog</h3>
{/exp:channel:entries}
</div>
This doesn't really seem the right way to use the {exp:channel:entries} tag. You mentioned "ebook_offer" was a channel field. But here you're using it as a static id for an HTML div. If "ebook_offer" is a field I would expect something like this:
<h3>Ebook</h3>
{exp:channel:entries channel="test"}
{ebook_offer}
{/exp:channel:entries}
Same with "about_blog"
<h3>About Obsia's Blog</h3>
{exp:channel:entries channel="blog_sidebar"}
{about_blog}
{/exp:channel:entries}
Also I noticed you said the channel was named "sidebar" but in your {exp:channel:entries} tag you're using "blog_sidebar". Which isn't the same thing, is your channel's shortcode "sidebar" or "blog_sidebar"?
Finally this is a little off to me
<div id="demo" dynamic="no" limit="1">
</div>
"dynamic" and "limit" only work on ExpressionEngine {exp:channel:entries} tags, not regular HTML elements (like DIVs). I would try using Bitmanic and Peter's suggestion again, but apply it to {exp:channel:entries} like so:
{exp:channel:entries channel="blog_sidebar" dynamic="off"}
...
{/exp:channel:entries}
If you're new to ExpressionEngine I highly recommend videos & tutorials by Ryan Ireland http://eeinsider.com/videos

Resources