Open a file when click on article

Hi, I'm back here .. with a borderline question ..
Is it possible to configure a theme so that when the user clicks on an article, a PDF file opens ?
I've read another similar post but I'm not sure it accomplishes the same thing
thank's in advance
Luca
1 year 5 months ago #1 by Luca
The topic has been marked as resolved.
  • Posted by TemplatePlazza (5184) Offline
Hi Luca,
How will you add the pdf link to the articles?
1 year 5 months ago #2 by TemplatePlazza
The topic has been marked as resolved.
If it were possible, I would like to be able to put in the title of the article a text that is a link to a pdf saved on the server.
alternatively, use the title of the article to show the description and insert the link to the PDF in the text of the article
or on the links page as in the attached image
thanks for your support
Luca
1 year 5 months ago #3 by Luca
The topic has been marked as resolved.
  • Posted by TemplatePlazza (5184) Offline
Hi, You can do that by using template override. If you don't know how to create a template override you can follow this video:


After you have created the template override, then open the override for the active minifrontpage theme, then add this line right after the foreach :
$urls = json_decode($item->urls);
$urla = $urls->urla;

Then replace all these codes :
<?php echo $item->link; ?>
with
<?php echo $urla; ?>
1 year 5 months ago #4 by TemplatePlazza
The topic has been marked as resolved.
great!!
It is exactly what I was looking for!

Two more questions:

Is it possible to open the file in a new window as a target?

With override of the default theme, I get the same behavior for all modules that point to defaut as a theme.
would it be possible to duplicate the default theme, for example in default_link in order to override the default_link theme and keep the original behavior for the default theme?
thanks
Luca
1 year 5 months ago #5 by Luca
The topic has been marked as resolved.
  • Posted by TemplatePlazza (5184) Offline

Is it possible to open the file in a new window as a target?

You just need to add target to the <a> tag right?
<a href="<?php echo $urla; ?>" target="_blank" ..

With override of the default theme, I get the same behavior for all modules that point to defaut as a theme.
would it be possible to duplicate the default theme, for example in default_link in order to override the default_link theme and keep the original behavior for the default theme?
thanks
Luca

You can make a condition, so if link A is empty it will back to the original behaviour
$urls = json_decode($item->urls);
if($item->urls) {
	$urla = $urls->urla;
}else{
	$urla = $item->link;
}
1 year 5 months ago #6 by TemplatePlazza
The topic has been marked as resolved.
Powered by Kunena Forum