News:

Dear forum visitors, if the support forum is not available, please try again a few minutes later. Thanks!

Main Menu
Support-Forum

Placeholder file title without html

Started by Tazzios, 27.08.2022 09:57:51

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Tazzios

The placeholder {file_title} contains an edit button behind the title. When using the placeholder in pdfviewer placeholder like below
Quote
{pdfviewer jdownloadsid={file_id} filename="{file_name}" style="popup" linktext="{file_title}"}
it breaks.(see image)

In my pdfviewer code i already remove the htmlcode directly at the start so i think it has something to do how joomla handles the placeholders.
So if there could be a placeholder in the 'download' and 'download details' layout with only the title text that would be great. ({file_title_text} ?)

more info:
https://github.com/Tazzios/pdfviewer/issues/17

ColinM

#1
Tazzios
The edit icon gets placed there if the usergroup to which the user belongs has the relevant permissions.  The Layout variable {file_title} only contains the actual title as a link.  If the user does not have permissions to download then the title is plain text.
A typical  link is
http://localhost/jdx38/index.php/list-all-downloads?task=download.send&id=51&catid=28&m=0targe
where id is the entry in the relevant database table. So processing that is not simple

There is a layout variable called {file_name} which does return the name of the file as a text string

See https://www.jdownloads.net/documentation-for-v3-9/layouts-v3-9/layouts-place-holders
for a list of all placeholder variables available in various layouts.

Colin
Colin M
  •  

Tazzios

#2
The 'file name' can be totally different from the 'title' and 'file name' also contains the extension, example: 'dfdf5434.pdf' vs 'Testfile One'.
I tested your suggested {file_title} for non logged-in user it indeed works, but it gets confusing if it works for some users and not for some others.

Looking in the Code:
In content plugin file (/plugins/content/jdownloads.jdownloads.php) there already seems to be an undocumented {file_title_only} but is unclear to me when this is used, editing or even deleting the file did not have any effect.
Digging a bit further I found the related files, To get the tag working at the following views needs the following lines:

/components/com_jdownloads/views/category/tmpl/default.php
newline 1505:
$html_file = str_replace('{file_title_only}',$files[$i]->title, $html_file);   

/components/com_jdownloads/views/downloadS/tmpl/default.php
newline 1130:
$html_file = str_replace('{file_title_only}',$items[$i]->title, $html_file);

/components/com_jdownloads/views/download/tmpl/default.php
newline 448:
$body = str_replace('{file_title_only}', $item->title, $body);

ColinM

Tazzios
The File Title and File Name are totally different in principle.  I would rather not  use other variants of file_title  as really it should be called 'download_title' and this might happen in jD4. 

I strongly believe we should stick with {file_name}.  As you say this does include the extension but I thought you would want to know that it is indeed (well probably) a pdf file as a first level check.

{file_name} works for all users. BUT it is not supported in the MyDowloads view - this is a bug and will be fixed.

Stripping off the extension in your code is surely very easy - :)

Also I would rather not introduce another layout variable, particularly at this time - we have more than enough to do with jD4.
Best wishes
Colin
Colin M
  •  

Arno

Hi,
Quote{file_name} works for all users. BUT it is not supported in the MyDowloads view - this is a bug and will be fixed.
The file name is not displayed here only if the external link option is used. 

I also think it would be easiest if you removed the file type from the file name in your source code. But I have never taken a look at it.
Best Regards / Gruß
Arno
Please make a Donation for jDownloads and/or write a review on the Joomla! Extensions directory!
  •  

Tazzios

Quote from: Arno on 29.08.2022 14:09:38
Hi,The file name is not displayed here only if the external link option is used. 

I also think it would be easiest if you removed the file type from the file name in your source code. But I have never taken a look at it.
Removing the file type from file name does not give me the file title (plaintext).

{file_title_only} already exist in the content plugin code so i thought just to add the same to the layout code.