We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Best practice advice?

Development and Programming

Brian M.'s avatar
Brian M.
529 posts
17 years ago
Brian M.'s avatar Brian M.

So I’ve created an extension that allows you to hide weblogs from the publish tab. But I’ve done it in a way which feels very hackish, and doesn’t seem like a good long-term solution.

All I really need to do is to insert 2 lines of code in $DSP->page_navigation(), but the only way I can see to do it is to use the “cp_display_page_navigation” extension hook, and so I need to replace that entire function.

To do that I’ve just taken that entire function and put it into my extension, and added my 2 lines of code.

It works like a champ, but like I said this doesn’t seem like a viable long-term strategy for doing this. At any time the official page_navigation() function could be updated, but my extension won’t reflect this and will be using the old code since it’s now in my extension. So then I would need to keep multiple versions of my extension - have a new one for each version that has a change in the page_navigation function - and I would need to make sure to keep each of these available for myself or others who are running different versions of EE.

What is good practice here? Like I said, all I need to do is add 2 lines of code to a function that is about 500 lines long.

Thoughts?

       
Daniel Walton's avatar
Daniel Walton
553 posts
17 years ago
Daniel Walton's avatar Daniel Walton

Hi Brian,

If you do a print_r($SESS->userdata[‘assigned_weblogs’]) you’ll see that the weblogs you have access to are stored in that array. You could use the same hook you’re using now to just unset() the elements of the array that correspond to the weblogs you want to hide.

This may have the side effect of also hiding entries in those weblogs from the edit page also, but thats a bonus right? :D

EDIT: Just tried it and no, they will still show on the edit page.

       
Brian M.'s avatar
Brian M.
529 posts
17 years ago
Brian M.'s avatar Brian M.

You’re the man.

Well I guess you’re the butcher, but I think it still applies 😉

       
Brian M.'s avatar
Brian M.
529 posts
17 years ago
Brian M.'s avatar Brian M.

If you click on the publish link in the CP page, you’re taken to a page that shows a list of weblogs you can publish to. Where is this page located - and can I use an extension hook to modify it or do I need to hack it if I don’t want these weblogs to show there either?

Thanks!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.