I have had a few clients ask to have the read more link open in a new window.

It would be useful if there was an option to select a target for the link.

Comments

agileware’s picture

Status: Active » Needs review
StatusFileSize
new4.41 KB
new4.42 KB

Here is a patch for this functionality.

I made it for a site running views 2 so I have tested the views 2 patch.

For views 3 I just made the views 2 patch apply, I haven't actually tested it.

The views 2 patch is against 6.x-2.x-dev
The views 3 patch is against 6.x-3.0-alpha2

merlinofchaos’s picture

I can't decide if the UI complexity of this feature is worth the minimal use it would get, when you can theoretically do this just by theming the more link.

rizz23’s picture

I tried the views-2 patch with a 6.x-2.8 Views module, but it seems not to be working for me.

How do I theme the views-more.tpl.php file to get the more link target to a new window?

agileware’s picture

What part of the patch isn't working?

Are you selecting a different target in the view settings and it isn't applying to the view?

As merlinofchaos said in #2 you can already achieve this without this patch by modifying the template file.
To do this you would change (in views-more.tpl.php):

<a href="<?php print $more_url ?>">

to:

<a href="<?php print $more_url; ?>" target="_blank">

or something similar depending on your desired target.

The purpose of this patch is so you can do this without any coding.
It allows you to do it from the views settings screen in the more link settings part.
So to finally answer your question you do not need to change views-more.tpl.php if using this patch.

rizz23’s picture

Are you selecting a different target in the view settings and it isn't applying to the view?

Yes, this is the point.

In the end I solved my problem theming the template as described in other 3ds I found after posting here.

Still, I'd like to use the patch, so please let me know if there is some known issue I should check.

Thanks,

Stefano

agileware’s picture

The only thing I can think of is that this patch changes the views-more.tpl.php file so if you are overriding that file in your theme you will have missed that change.

If so you will need to make the same change to your views-more.tpl.php file.

Change the line:

<a href="<?php print $more_url ?>">

to:

<a href="<?php print $more_url; ?>" target="<?php print $link_target; ?>">
dawehner’s picture

Status: Needs review » Needs work

If we add this feature i suggest to support the views tokens. If you have arguments this will be needed often.

I hope it's okay to set CNW

esmerel’s picture

Status: Needs work » Closed (won't fix)

No work done on patch in more than 3 months.

botris’s picture

Being able to select the target for individual displays & views would be great. views-more.tpl.php is, as far as I know, for every view. The patch fails (views 2.12) at Hunk #7:
It searches for
return theme($theme, $path, $this->use_more_text()); while the code is
return theme($theme, $path, check_plain($this->use_more_text())); and should be replaced with
return theme($theme, $path, check_plain($this->use_more_text()), $this->use_more_target());
But then still the patch doesn't respect displays, so the target is set for all displays regardless if you override the default view.