rejetto forum

Links in new tab

0 Members and 1 Guest are viewing this topic.

Offline Alexey227

  • Occasional poster
  • *
    • Posts: 4
    • View Profile
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



Offline LeoNeeson

  • Tireless poster
  • ****
    • Posts: 842
  • Status: On hiatus (sporadically here)
    • View Profile
    • twitter.com/LeoNeeson
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>
« Last Edit: May 16, 2017, 08:04:35 AM by LeoNeeson »
HFS in Spanish (HFS en Español) / How to compile HFS (Tutorial)
» Currently taking a break, until HFS v2.4 get his stable version.


Offline Alexey227

  • Occasional poster
  • *
    • Posts: 4
    • View Profile
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 :)


Offline LeoNeeson

  • Tireless poster
  • ****
    • Posts: 842
  • Status: On hiatus (sporadically here)
    • View Profile
    • twitter.com/LeoNeeson
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.
HFS in Spanish (HFS en Español) / How to compile HFS (Tutorial)
» Currently taking a break, until HFS v2.4 get his stable version.


Offline Alexey227

  • Occasional poster
  • *
    • Posts: 4
    • View Profile
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


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
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'>


Offline Alexey227

  • Occasional poster
  • *
    • Posts: 4
    • View Profile