rejetto forum
Software => HFS ~ HTTP File Server => Topic started by: Alexey227 on May 16, 2017, 07:02:52 AM
-
Hello
How can I set a condition?
if link is file then open in an new window/Tab
if link is folder then open In this window
-
Hi!, welcome to the forum! :D
This could be done by editing the template and using Macros. I don't know how to do it, but some other user will surely help you. Normally, in plain HTML, this is done by adding target="_blank" in a link. Example:
<a target="_blank" href="http://www.rejetto.com/hfs/">HFS</a>
-
But HFS not just html :)
I use the standard template and this example code сell drawing (line 272)
{.if|{.get|is new.}|<span class='flag'> NEW </span>.}
{.if not|{.get|can access.}|<img src='/~img_lock'>.}
<a href="%item-url%"><img src="%item-icon%"> %item-name%</a>
{.if| {.length|{.?search.}.} |{:{.123 if 2|<div class='item-folder'>{.!item folder.} |{.breadcrumbs|{:<a href="%bread-url%">%bread-name%/</a>:}|from={.count substring|/|%folder%.}/breadcrumbs.}|</div>.}:} .}
{.123 if 2|<div class='comment'>|{.commentNL|%item-comment%.}|</div>.}
I understand that I need to write a condition in a string <a href="%item-url%">
But I do not understand how to do it correctly :)
-
Try this! :)
In this line...
<a href="%item-url%"><img src="%item-icon%"> %item-name%</a>
Add the code marked in red:
<a {.if| {.%folder% = / .} | target="_blank" .} href="%item-url%"><img src="%item-icon%"> %item-name%</a>
...but this is not working with subfolders! :( so, my code syntax must be bad!
I'm sure other users (which are more expert than me), will help you.
-
Thank you! Now I understand this syntax a little :D
well i use %item-size% to create the condition
<a {.if| {.%item-size% != 0 .} | target="_blank" .} href="%item-url%"><img src="%item-icon%"> %item-name%</a>
I hope there is a better version of this ;D
-
in the wiki and here (http://www.rejetto.com/forum/html-templates/hfs-templates-vars-and-section-help/)
you can find a variable named %item-type%
%item-type% Return the value according the same section name, when item is folder, file or link
<a {.if|{.%item-type% = folder .}|target="_blank".} href="%item-url%"><img src="%item-icon%"> %item-name%</a>
Another way of doing this, is to explode the section [file=folder=link|private] into several pieces
[file=folder=link|private]
<tr class='{.if|{.mod|{.count|row.}|2.}|even.}'><td>
<input type='checkbox' class='selector' name='selection' value="%item-url%" {.if not|{.or|{.get|can delete.}|{.get|can access.}|{.get|can archive item.}.}|disabled='disabled'.} />
{.if|{.get|is new.}|<span class='flag'> NEW </span>.}
{.if not|{.get|can access.}|<img src='/~img_lock'>.}
[+folder]
<a href="%item-url%" target="_blank">
[+file=+link]
<a href="%item-url%">
[+file=+folder=+link]
<img src="%item-icon%"> %item-name%</a>
{.if| {.length|{.?search.}.} |{:{.123 if 2|<div class='item-folder'>{.!item folder.} |{.breadcrumbs|{:<a href="%bread-url%">%bread-name%/</a>:}|from={.count substring|/|%folder%.}/breadcrumbs.}|</div>.}:} .}
{.123 if 2|<div class='comment'>|{.commentNL|%item-comment%.}|</div>.}
[+file]
<td>%item-size%B<td>%item-modified%<td>%item-dl-count%
[+folder]
<td class='nosize'>{.!folder.}<td>%item-modified%<td>%item-dl-count%
[+link]
<td class='nosize'>{.!link.}<td colspan='2'>
-
Thank you very much!