rejetto forum

Software => HFS ~ HTTP File Server => Topic started by: Alexey227 on May 16, 2017, 07:02:52 AM

Title: Links in new tab
Post 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

Title: Re: Links in new tab
Post by: LeoNeeson on May 16, 2017, 07:58:01 AM
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:

Quote
<a target="_blank" href="http://www.rejetto.com/hfs/">HFS</a>
Title: Re: Links in new tab
Post by: Alexey227 on May 16, 2017, 08:48:26 AM
But HFS not just html :)
I use the standard template and this example code сell drawing (line 272)

Code: [Select]

{.if|{.get|is new.}|<span class='flag'>&nbsp;NEW&nbsp;</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
Code: [Select]
<a href="%item-url%">
But I do not understand how to do it correctly :)
Title: Re: Links in new tab
Post by: LeoNeeson on May 16, 2017, 10:18:39 AM
Try this! :)

In this line...
Code: [Select]
<a href="%item-url%"><img src="%item-icon%"> %item-name%</a>
Add the code marked in red:
Quote
<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.
Title: Re: Links in new tab
Post by: Alexey227 on May 16, 2017, 10:29:47 AM
Thank you! Now I understand this syntax a little :D

well i use %item-size% to create the condition

Code: [Select]
<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
Title: Re: Links in new tab
Post by: Mars on May 16, 2017, 08:40:50 PM
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

Code: [Select]
[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'>&nbsp;NEW&nbsp;</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'>
Title: Re: Links in new tab
Post by: Alexey227 on May 17, 2017, 05:00:14 AM
Thank you very much!