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

Hook into where there is no hook?

Development and Programming

Triad's avatar
Triad
44 posts
14 years ago
Triad's avatar Triad

First id like to apologise if im asking any stupid questions, i have checked the docs but am not finding the answers to the questions i have. Ultimately all these boil down to one question… I figure there arent hooks to do what i want currently, should i code in hooks where i need them?

If you’re interested in details:

First, what im doing requires that i replicate that a field has been added and add a similar field to my table.

I can do that when the module has been installed, and could (i guess) have a sync button on my module admin screen, but itd be much nicer to do it at the point that a field were added.

Second, i need to deliver a fair amount of html to the tab of the publish / edit screen on my module, along with some jquery magic to be able to pull of what i need. Ultimately its just form fields, but with some cleverness. Is there an easy way to do this?

Third, id like to declare some new ‘global’ variables for templates. I figure i COULD write a plugin to do it, but {myplugin}{mytag}{/myplugin} is not as intuitive as {mytag}. If i could mash in some of my own variables into the globals when the globals are loaded, that would be mega useful. Just a thought, mind you.

I did tweet a few people yesterday, hopefully this will make my request a little clearer to anyone who was baffled then…

Any ideas would be great.

       
Triad's avatar
Triad
44 posts
14 years ago
Triad's avatar Triad

This looks like it could come to my aid in the first instance…

http://ellislab.com/forums/viewthread/191432/

       
Wes Baker's avatar
Wes Baker
343 posts
14 years ago
Wes Baker's avatar Wes Baker

Triad,

Since this is more of a Development question, I’m going to move this to the Development and Programming forum.

Wes

       
Triad's avatar
Triad
44 posts
14 years ago
Triad's avatar Triad

Ah, thanks.

       
Triad's avatar
Triad
44 posts
14 years ago
Triad's avatar Triad

Still having an issue here..

       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
14 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team
…should i code in hooks where i need them?

That’s dependent on if you want the product supported by EllisLab and an easy time upgrading EE in the future. The fact is that you technically can add in hooks and use them. We’ve done it a few times. You just have to maintain that in further releases. With a well documented project that’s not really so bad.

First, what im doing requires that i replicate that a field has been added and add a similar field to my table. I can do that when the module has been installed, and could (i guess) have a sync button on my module admin screen, but itd be much nicer to do it at the point that a field were added.

Before diving into that further, did the other post you mentioned answer this question?

Second, i need to deliver a fair amount of html to the tab of the publish / edit screen on my module, along with some jquery magic to be able to pull of what i need. Ultimately its just form fields, but with some cleverness. Is there an easy way to do this?

Sounds like you could just write an add-on for that. http://ellislab.com/expressionengine/user-guide/development/modules.html#tab_file

Third, id like to declare some new ‘global’ variables for templates. I figure i COULD write a plugin to do it, but {myplugin}{mytag}{/myplugin} is not as intuitive as {mytag}. If i could mash in some of my own variables into the globals when the globals are loaded, that would be mega useful. Just a thought, mind you.

It’s possible to add to the global variable array in an extension hook. I’ve done that in a few add-ons. A great example is Low’s Seg2Cat. You can see here how he’s created new variables and merged them into the existing global var array from within the sessions_end hook. https://github.com/lodewijk/low.seg2cat.ee2_addon/blob/master/low_seg2cat/ext.low_seg2cat.php#L364

       
Triad's avatar
Triad
44 posts
14 years ago
Triad's avatar Triad

Erik, that was a hugely helpful reply… thanks very much!

       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
14 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team

Fantastic! Let us know how it goes and if you hit questions along the way

       
Triad's avatar
Triad
44 posts
14 years ago
Triad's avatar Triad

For the record, the link i found wasnt quite what i was hoping it is. It looked to be a way to create a hook where there was none, but its not low level enough.

Iv ended up writing a custom hook, but thats just fine, because it works, and iv documented its location if ever we upgrade and need to re-enable it.

Will keep you posted, because it should be quite a useful module / extension when its all done.

       
Triad's avatar
Triad
44 posts
14 years ago
Triad's avatar Triad

How do i publish custom html to the module tab? I can publish fields, i know, but id like to make the system a little nicer to use, by using a bit of jquery to switch around some fieldsets on my tab.

Feel like im missing something…

       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
14 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team

I’m actually not sure. I’ve not tried to add in js to a page with a module tab before. I know of a few ways to add js/css to the document’s head but I haven’t tried it in a tab file. I’ll experiment a little if you don’t beat me to it.

       
jwindhorst's avatar
jwindhorst
99 posts
14 years ago
jwindhorst's avatar jwindhorst

The custom html in your modules control panel pages is as simple as creating a views directory inside your module directory. system/expressionengine/MyModule/views/index.php I would recommend grabbing taxonomy and looking through his layout. It’s fairly straight forward, and has some helpful code if you’re new to writing your own modules. I actually have to to the same thing when a column is added to a database. There is thread discussing my solution over here:

http://ellislab.com/forums/viewthread/191432/

Good luck

       
Triad's avatar
Triad
44 posts
14 years ago
Triad's avatar Triad
The custom html in your modules control panel pages is as simple as creating a views directory inside your module directory. system/expressionengine/MyModule/views/index.php I would recommend grabbing taxonomy and looking through his layout. It’s fairly straight forward, and has some helpful code if you’re new to writing your own modules. I actually have to to the same thing when a column is added to a database. There is thread discussing my solution over here: http://ellislab.com/forums/viewthread/191432/ Good luck

Thanks for that, what im after tho is custom layout on the publish tab.

Module views is fine, but ill definately need to output my own html to the publish tab…

       
Triad's avatar
Triad
44 posts
14 years ago
Triad's avatar Triad

Using ‘$this->EE->javascript->output’ to output jquery, and using jquery to manipulate the output fields to be in the order / layout i need.

Not ideal, but it’ll work.

       

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.