Ticket #882 (closed enhancement: duplicate)
Add a coreBeforeBlogGetPosts behavior
Reported by: | dooblem | Owned by: | xave |
---|---|---|---|
Priority: | normal | Milestone: | 2.2 |
Component: | module:core | Version: | 2.1 |
Severity: | normal | Keywords: | |
Cc: |
Description
When a post url is given, say : http://blogurl/post/MyPost
The default way is to call the post function in lib.urlhandlers.php, then the getPosts function with MyPost? as argument in class.dc.blog.php.
Problem for the dctranslation plugin : we need to look for the post_url (MyPost?) in another db table (dc_translation). How do I change the behavior of the getPosts function ?
Possible solutions to implement that in the plugin :
- redefine the post function if possible --> ugly
- redefine the getPosts function if possible --> ugly
- add a new behavior call --> simple !
I added a new behavior call in my getPosts dotclear function (see added patch).
Any other Idea is greatly appreciated.
Thanks in advance all, and for providing DC to us !
Marc
Attachments
Change History
comment:1 Changed 15 years ago by bruno
Don't forget that such a behavior may be called from many places : from the public side, but also from the admin side, since this is a core function. So if it gets implemented, how can we make sure that the plugin that will implement this behavior will know when to act ? Do we want him to act even on the admin side ?
Concerning your use case, it would be better to act before the getPosts call. I would advise to opt for resolution of #896, ie. to tweat directly the args passed to the post urlhandler.
comment:2 Changed 15 years ago by bruno
Do not conclude that I do not deny the need for such a behavior (it may be suitable for some cases), but that I don't think that it would be the best way to solve your problem :)
comment:3 Changed 15 years ago by xave
- Status changed from new to closed
- Resolution set to duplicate
Ok, that need can be covered with #986, let's call this one a duplicate until further notice.
comment:4 Changed 15 years ago by dooblem
xave: I don't see the point with issue #986. Can you explain me ?
bruno: in my use case, it is only useful in the public side. Is the getPosts function also called in the admin side ?
comment:5 Changed 15 years ago by xave
getPosts is called by url handlers, determining wich url handler is to be called is done based on $args, interception of those arguments allow you to call anything you want: say the url is /post/2012/12/12/end-of-the-world, you can rewrite the $args to /pages/bullshit, and that's what will be called internally. You can also write your own url handler to serve anything you want.
Besides, the coreBlogGetPosts behaviour offers you many other possibilities.