rejetto forum

How can I implement thing on image attached?

D · 9 · 5609

0 Members and 1 Guest are viewing this topic.

Offline D

  • Occasional poster
  • *
    • Posts: 28
    • View Profile
I need folder names to have additional link attached automatically, with part of foldername in it:

Folder "A - B C 3" [link to example.site/view-2.php?name=A]
or
Folder "A - B C 3" [link to example.site/view-2.php?name=A: B C III]

1. How can I use foldername as variable?
2. How can I edit that variable? (%20- = %3A)
3. How can I add my link through diff template?
« Last Edit: March 15, 2021, 02:33:45 AM by D »


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2063
    • View Profile
use  %item-name% and update the value  using some macros replace, substring, cut , trim .. to include the result in the url link
http://www.rejetto.com/wiki/index.php?title=HFS:_scripting_commands


« Last Edit: March 15, 2021, 02:16:06 PM by Mars »


Offline D

  • Occasional poster
  • *
    • Posts: 28
    • View Profile
But how do I insert my code into template? I tried:
Code: [Select]
[+folder]
%item-name%
this edits "Hits" column instead of "Name" one

Putting this into head of hfs.tpl worked for me:
Code: [Select]
<script type="text/javascript">
  document.addEventListener('DOMContentLoaded',function(){
    let reg1=/~img_folder"> (.*)</g;
    let reg2='~img_folder"> $1 </a> [<a href="http://example.site/view-2.php?name=$1" >Info</a>]<';
    document.body.innerHTML=document.body.innerHTML.replace(reg1,reg2);
    let reg3=/view-2.php\?name=(.*)( \-)(.*?)">/
    let reg4='view-2.php\?name=$1:$3">';
    document.body.innerHTML=document.body.innerHTML.replace(reg3,reg4);
    });
</script>
however it works globally, not only for folder I want.


Offline danny

  • Tireless poster
  • ****
    • Posts: 281
    • View Profile
If the folder you want is the current folder, that is %encoded-folder%

See also this for more macro fun:  http://rejetto.com/forum/index.php?topic=12059.msg1065252#msg1065252

Separation of (additional) functions works with filetypes, users, groups. . . But not the parent folder, because the time-travel functionality was already redacted by the future developers (surely doable; but, the costs are inconvenient).   ;)  (not easy to separate by parent folder contents that have not yet been seen). 

P.S.
The traditional way is user-group to identify special folders (before the contents have been seen).   However, if you're not going with login > users > groups to differentiate, then you can use the .exec macro for diy scanner (to flag content, before the end-user arrives).
« Last Edit: March 16, 2021, 07:11:53 PM by danny »


Offline D

  • Occasional poster
  • *
    • Posts: 28
    • View Profile
You asked me to elaborate what I'm trying to do.

Let's say I want to include this feature for folder "My"


The script above works, but globally. I only need it for folder "My"

Editing diff template



results in this



Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2063
    • View Profile
the section [file=folder=link|private]  containt the division of column name

use the totality of this text as a starting point to put in the diff template properties , instead of what you put there previously

Quote
[file=folder=link|private]
<div class='item item-type-%item-type% {.if|{.get|can access.}||cannot-access.} {.if|{.get|can archive item.}|can-archive.}'>
   <div class="item-link">
      <a href="%item-url%">
         <img src="%item-icon%" />
         %item-name%
      </a>
      {.if|{.=|%item-type%|folder.}|{:[<a href="http://example.site/view-2.php?name={.encode html|%item-name%.}"> Info </a>]:}.}
   </div>
   <div class='item-props'>
      <span class="item-ts"><i class='fa fa-clock-o'></i></span>

[+file]
      <span class="item-size"><i class='fa fa-download' title="{.!Download counter:.} %item-dl-count%"></i> %item-size%B</span>
[+file=folder=link]
      {.if|{.get|is new.}|<i class='fa fa-star' title="{.!NEW.}"></i>.}
[+file=folder]
        <button class='item-menu pure-button' title="More options"><i class="fa fa-bars"></i></button>
[+file=folder=link]
    </div>
   <div class='clearer'></div>
[+file=folder=link]
    {.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'><i class="fa fa-quote-left"></i><span class="comment-text">|{.commentNL|%item-comment%.}|</span></div>.}
</div>


« Last Edit: March 16, 2021, 10:00:50 PM by Mars »


Offline danny

  • Tireless poster
  • ****
    • Posts: 281
    • View Profile
You asked me to elaborate what I'm trying to do....
Kudos for that. 
Unfortunately, I'm a bit daft and didn't manage to get past editing of an older template which was slow and so huge that the editing is difficult.  Maybe it would be good to use something more streamlined?  For example, the Takeback template has a lot of features but also more speed and less bulk. 
« Last Edit: March 18, 2021, 10:37:12 AM by danny »


Offline dj

  • Tireless poster
  • ****
    • Posts: 291
  • 👣 🐾
    • View Profile
    • PWAs
alt. without macros

Code: [Select]
[+]
<script>
[...document.querySelectorAll('#files a[href$="/"]')].forEach(item =>
 item.insertAdjacentHTML('afterend', '<a href="http://example.site/view-2.php?name='+item.innerText.trim()+'"> Info </a>')
)
</script>


Offline D

  • Occasional poster
  • *
    • Posts: 28
    • View Profile
Code: [Select]
[+]
<script>
[...document.querySelectorAll('#files a[href$="/"]')].forEach(item =>
 item.insertAdjacentHTML('afterend', '<a href="http://example.site/view-2.php?name='+item.innerText.trim()+'"> Info </a>')
)
</script>
godsend
« Last Edit: March 18, 2021, 01:18:57 AM by D »