How to link an URL inside the them from the Diazo rules file? - themes

If an URL to a image is set in a HTML template, then the URL is updated to reference files inside the theme folder. For example,
<img src="image.png" />
is replaced by:
<img src="http://localhost:8080/mysite/++theme++mytheme-theme/image.png" />
However, if I write following Diazo rule:
<replace css:content="#some-class">
<div id="#some-class"><img src="image.png" /></div>
</replace>
the URL of the image is not update. How can I write Diazo rules where the image gets correctly referred. I want to refer this image in the template HTML file with <img src="path/image.png">. However it is not clear what to put instead of path. I notice that path cannot be an absolute path because it depends of the site domain. Also, it cannot be a relative path because it depends on the path of each page in the site. May be it would be useful to have an specific keyword to reference the theme folder. For example, <img src="$themeFolder/image.png">. Exists such keyword?

You may create XSLT parameters in your theme's manifest.cfg file. Just add a stanza like:
[theme:parameters]
theme_base_url = string:${portal_state/portal_url}/++theme++mytheme-theme/
Then you may use it in your rules file:
<replace css:content="#some-class">
<div id="#some-class">
<img><xsl:attribute name="src"><xsl:value-of select='$theme_base_url' />image.png</xsl:attribute></img>
</div>
</replace>

Related

Thymeleaf parse text and execute in-text expressions

I have text string, that contains links, for example, like <a th:href="'someLink'">Download</a> .
I need to process that text and replace th:href="'someLink'" with correct links to show text with Download.
The text with links is stored in variable textThatContainsLinks.
My code to show text is <div th:utext="${textThatContainsLinks}">. I also tried to use preprocessing like <div th:utext="${__textThatContainsLinks__}">.
Currently this code shows links not as I expected, but non-preprocessed, ie, output is <a th:href="'someLink'">Download</a> now.
How to pre-process expressions in text, before showing it?
Thank you very much!
Take the context path and directly attach it to the relative path of a pure html5 attribute e.g LINK, <img src="/contextPath/relative/path/image.jpg" width="50" height="50" alt="logo"/>.
Notice how simple the accessibility to the resource is: /contextPath/relativePath, so the most important path there is the relative path. This is similar to Thymeleaf was unable to render <img> tag when sent from database table. I observed that once thymeleaf's namespace th: qualifies a href or src attribute that resides inside a text/String the absolute path is not properly resolved.

Custom image in footer (Prestashop)

I have a small question. I am using prestashop, and would like to add image in my footer. I am trying to add img tag in footer.tpl
<img src="/htdocs/themes/warehouse/img/logo_btm.png" alt="logo" />
but instead of picture i have question mark.
you use relative path
instead of relative path use full url to your image like
http://domain.com/link/to/image.jpg
You have to use smarty global var, put the image in your theme's image folder and use this syntax
<img src="{$img_dir}logo_btm.png" alt="logo" />

access the folder image docroot

I have a picture in glassfish docroot folder and display it but I need a relative path.
My code is as follows
<h:graphicImage value="/#{detalle.path} />
And it produces the following result: 'localhost:8080/Gestion/image.png'
I need something like 'localhost:8080/image.png'
Note: Path is the image name.
How do I get this? Thanks in advance
The <h:graphicImage value> implicitly prepends the context path in the URL. What you want is not possible with <h:graphicImage>. If you need to point to an image which is not part of the webapp, then just use plain HTML <img> instead.
<img src="/#{detalle.path}" />

How to style the output of <jdoc:include type="component" /> within templates?

is there any way to style the output of <jdoc:include type="component" /> within the templates without modifying Joomla core function?
Specifically, I would like to add a div with id article to include the article and nothing else. By now, in my theme, there's a div with class item-page that includes the article, the ratings, the action and even the comment box (added with an external plugin).
So, I would like the new templates to be something like:
<div class="item-page>
<!-- something here -->
<div id="article">
<!-- The article and nothing else here -->
</div>
<!-- comments and whatever may be here -->
</div>
Use a layout override.
Go to the tmpl folder of the view you want to modify the layout for and copy to the html folder of your template ... so say article:
get /components/views/article/default.php and copy that to
templates/[yourtemplate]/html/com_content/article/default.php
Modify the file as you wish.
This will default change it on all pages using that template.

grails images absolute path

I have this image in my header template <img src="images/slide-1.jpg" alt="Slide #1" width="175" height="77" />
When the template is used from a gsp file inside the 'main' directory, the image is loaded. Although, if I have the same template being used inside a gsp file inside a controller, the image is not loaded. I have tried to change this:
<img src="images/slide-1.jpg" alt="Slide #1" width="175" height="77" />
to this:
<img src="../images/slide-1.jpg" alt="Slide #1" width="175" height="77" />
and it works, but now the image in the other page don't. Any idea to solve the problem? I know the key must be absolute path. But i've done some searches and found nothing.
You can put your images in resource folder (for example, in YOUR_PROJECT/web-app/images) then access it in gsp by resource tag. By this way you won't have the absolute path problem.
For a concrete example, you can refer this question.
Try "${application.contextPath}/images/slide-1.jpg". It's a semi-absolute path that will work in any of your deployment environments.

Resources