Hi,
dereine has already posted a patch - see http://drupal.org/node/564106#comment-2014578 - allowing us to add a Custom URL in the More link in Views.
This is very useful and rtbc, however there is no possibility to add to that link an argument from panels, like a substitution pattern (e.g. %user:uid). The link would the look like "user/%" or similiar and print out something like "localhost/mysite/user/1".
Or what about php code? The link could then look like "user/ $user->uid; "?
How could this be achieved? There is interest in this functionality, as you see in http://drupal.org/node/564106
I'm opening a new issue for it, as the original issue is already marked rtbc.
Thanks
Comments
Comment #1
dicreat commentedSubscribe.
Comment #2
drupov commentedThis approach will probably make some of you laugh, but what I the following:
Applied patch http://drupal.org/node/564106#comment-2014578 to make a "Custom URL:"-field appear.
From here my goal was to "mirror" the way filter format options appear in the "Header", "Footer" or "Empty text" options in views (all these options have textareas where users can input Filtered HTML, Full HTML or PHP Code).
Following pieces of code I added to the patched file "plugins/views_plugin_display.inc":
Change line 169:
Add after line 243 ("'use_more_text' => TRUE,"):
Add after line 346 ("),"):
Add after line 916 ("),"):
I've added the already edited file "views_plugin_display.inc" (remember - after "views-more-url_0.patch") and a screenshot of the what it's achieved by it. This looks ok so far... but...
... The problem is - and that is why I started the post with "make some of you laugh" - that if you write php code in the "Custom URL"-field this filter choice isn't saved and therefore the value in the field is probably taken as "Filtered HTML" - so in other words nothing really happens. With my current knowledge I cannot see where to make this "Custom URL"-field accept the filter settings. The two are simply not connected... And security issues are not even taken into account at that stage...
But this could be a start or something. Hope someone can provide a better approach.
Thanks
Comment #3
dawehnerIf you make a Patch people could try this out much much easier.
Comment #4
drupov commentedI would - I was about to do it, but I cannot figure out the meaning of the value after the comma in the patch... :(
E.g. "@@ -166,7 +166,7 @@ class views_plugin_display extends views_plugin {" in
or "@@ -341,6 +341,9 @@ class views_plugin_display extends views_plugin {" in
Can you give me a short hint pls. I would really appreciate it! Thanks!
Update: I'll try to figure it out of course, you gave me a link, didn't see it, sorry.
Comment #5
drupov commentedHere is the patch! :)
Please apply it in the views/plugins directory.
Don't forget: it must be applied after http://drupal.org/files/issues/views-more-url_0.patch has been applied.
Comment #6
merlinofchaos commentedI prefer if all patches apply from the views directory, if we can.
Comment #7
drupov commentedSorry,
here is the patch applying from the views root directory.
Comment #8
drupov commentedI've added a line to the patch inside the function options_submit. That way the value given to the filter section of more_url is being submitted and "remembered".
"The problem" described in #2 still persists though (URL is being shown the same, no matter in "Filtered HTML" or "PHP Code"-format. I think the value in the textarea is not been rendered to go through the filter...
There is some code after line 1662 in views_plugin_display.inc that handle those tasks, but I cannot look through it...
Any ideas?
Comment #9
merlinofchaos commentedFirst, proper status.
Second: Why are there two issues for this? See http://drupal.org/node/564106 -- please combine these two issues and mark one as duplicate. Since both are active (and some are active in both issues) and both have patches, I"ll let you guys decide which to go with.
Comment #10
drupov commentedI think this issue here is the one that should be taken into account, as the other one ("More link to point to custom URL") has already been solved (you already have the possibility to add static URL-addresses to your "more" links in views).
I think issue http://drupal.org/node/564106 ca be marked as fixed and development of an arguments solution of views-more-links should go on here?
Comment #11
dawehner@mitkoru
Can you explain why we need input format?
We can use html currently.
I think we should first commit #564106: More links pointing to custom URLs don't respect entered fragments and query parameters and then whether we need input format here.
Comment #12
drupov commented@dereine
I'm passing my views to a "My profile" page which is handled by panels. There is a section, e.g. my friends and the more link of the view should look like "mysite/%/friends".
Now I know this can be overriden in panels:
- panels has a "Provide a "more" link that links to the view"-function - but you aren't able to change the "more"-text there.
- panels has also "Override URL:" function, where arguments from the URL are pluggable, which is what I want to achieve by views, through that php filter.
Why would I need that:
- to change the "more"-text to something like "See this user's friends" or even better "See Johnny's friends" (suppose the user is called Johnny).
- the "more"-link should provide a dynamic address to that user's friends, whose profile is being shown. I want to use the http://drupal.org/project/quicktabs module with views to save space on the profile page. In there every tab shows a separate view and that is where you cannot use panels "Override URL:"-function anymore as this single pane contains several views through Quicktabs and of course you wouldn't set the same URL for different "more"-links within that Quicktabs.
- you would have that problem anyway if you don't use panels and you need the "more"-link to show to a specific location, depending on what user or node you are viewing at the moment...
So it would be possible to get the User ID or Node ID being watched and put it into the Custom URL in views through php. This is very similiar functionality to what the header, footer or empty text fields in views offer.
Comment #13
jonskulski commentedPHP Code in the DB is hacky and will leads to issues. If tokens are exposed that should solve most issues. If not, someone could always write some PHP to expose a specialized token.
After some poking around, it looks there would be work to move the Tokens into the views object. Currently, a field will loop through all existing fields to find available tokens (through document_self_tokens()). This makes sense to move into the view object.
A function like $view->get_tokens() could encapsulate the code from lines 278 to 292 of view_handler_field:
Comment #14
agileware commentedSubscribing
Comment #15
merlinofchaos commentedStatus based on #13.
Comment #16
prasannah.ganeshan commentedHi,
I having the same problem with the views module. But I'm unable to use these patches.
First of all my problem starts at getting a custom link to the more link generated by the view. But I would be interested to know how it will work for arguments as well.
If someone had fixed this issue for a newer version of views module Please let me know.
-Prasannah
Comment #17
merlinofchaos commented#16:
Please read before you post. This issue is set 'needs work'. It has not been committed. The patch is not ready and needs work.
PLEASE do not post the same comment on multiple issues. That is a waste of everybody's time. If you want to help with the issue, please help. But copy-pasting your comment across issues is the opposite of help.
Comment #18
prasannah.ganeshan commentedThanks for the update. I actually wanted some work around for this urgently for requirement.
My problem is when I give a more link on a view it always points to that view. When the view appear on the homepage it only has 3 items shown. All I need is the users to click a more link to see all the content, which I would like to point to a different node.
If you have a work around for this apart from this patch, I would be greatly helpful to me.
Thanks Again for keeping me update of my mistake. Would avoid doing it in the future.:)
Comment #19
merlinofchaos commentedYou can override theme_views_more (and it supports all of the stuff that all the other themes support in terms of per view, per display, etc. See Theme: Information) -- from there you can rewrite the link however you need.
Comment #20
dawehnerCould someone check whether this is a duplicate of #578834: More link to point to custom URL - Arguments enhanced ?
Comment #21
jonskulski commenteddereine,
Did you mean to link to this thread or were you trying to start a philosophical debate? Is an issue a duplicate of itself? ;-)
Comment #22
dawehnerHehe.
Mh there was a issue with a similar patch. The issue i wanted to link implemented this not as a readmore link but as a display link, which is the more general approach.
Let's hope we can find the issue in the depths of the views issue queue.
Comment #23
coolhandlukek2 commentedSubscribe
Comment #24
dstolsubscribing
Comment #25
gregoiresan commentedComment #12 by mru :
"- panels has also "Override URL:" function, where arguments from the URL are pluggable, which is what I want to achieve by views, through that php filter."
I'm trying to plug them but I encounter difficulties such as multiple arguments in the new URL or appear in different locations as wanted. Is there any trouble with the "send arguments" option (which I need to get the argument in my original view) ?
Comment #26
nitebreedSubscribing
Comment #27
locomo commentedsubscribe
Comment #28
dagmarMarking as duplicate of #564106: More links pointing to custom URLs don't respect entered fragments and query parameters as merlinofchaos requested here: http://drupal.org/node/578834#comment-2083184
Comment #29
iamjon commentedmarked #578834: More link to point to custom URL - Arguments enhanced as duplicate.
Comment #30
kellyimagined commentedEdit View
Advanced section
Other
Link Display
You can specify the page or custom url.