![]() |
html helper heading() - No class/id args accepted? Do I have to extend? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: html helper heading() - No class/id args accepted? Do I have to extend? (/showthread.php?tid=34570) |
html helper heading() - No class/id args accepted? Do I have to extend? - El Forum - 10-03-2010 [eluser]stormbytes[/eluser] Trying to use the header() helper function (html helper) to generate a heading, it doesn't seem to accept any arguments beyond text string & heading level. Either I'm overlooking something (entirely possible) or this has got to be an oversight. If so, would I have to extend the helper function to provide for id/class? How would I go about that? html helper heading() - No class/id args accepted? Do I have to extend? - El Forum - 10-03-2010 [eluser]wiredesignz[/eluser] The heading helper only has the two parameters that you describe. You will need to extend it. Create MY_html_helper.php in application helpers add the new functionality there. html helper heading() - No class/id args accepted? Do I have to extend? - El Forum - 10-03-2010 [eluser]stormbytes[/eluser] [quote author="wiredesignz" date="1286176997"]The heading helper only has the two parameters that you describe. You will need to extend it.[/quote] Is the procedure for extending helpers in the UG? What's a good start? html helper heading() - No class/id args accepted? Do I have to extend? - El Forum - 10-03-2010 [eluser]wiredesignz[/eluser] Inside the application/helpers/MY_html_helper.php I have added and modified the original code like so: Code: function heading($data = '', $h = '1', $attribs = '') html helper heading() - No class/id args accepted? Do I have to extend? - El Forum - 10-03-2010 [eluser]stormbytes[/eluser] [quote author="wiredesignz" date="1286177109"]No real names in here please.[/quote] Fixed - sorry about that html helper heading() - No class/id args accepted? Do I have to extend? - El Forum - 10-03-2010 [eluser]wiredesignz[/eluser] Yeah you don't need to quote me when you are the very next post buddy. I have edited my previous post to provide an example for you. Usage would be something like: Code: echo heading('My Heading;, 2, 'class="some_class" id="some_id"'); Attributes only needs to be a string. ![]() html helper heading() - No class/id args accepted? Do I have to extend? - El Forum - 10-03-2010 [eluser]stormbytes[/eluser] Oki doke - Will catch on to the etiquette soon enough. Thanks for the example. I'll look it over. Question that pops out - Does this override the normal 'heading()' helper function? Actually.. I can probably RTFM on that on.. html helper heading() - No class/id args accepted? Do I have to extend? - El Forum - 10-03-2010 [eluser]stormbytes[/eluser] Well that does simplify it - I'll still study the previous example, just for kicks. Thanks! html helper heading() - No class/id args accepted? Do I have to extend? - El Forum - 10-04-2010 [eluser]stormbytes[/eluser] I cleaned it up a bit, validated input, and added conditional spaces to make the finished tag look a bit cleaner. With a custom Textmate command (bundles) this rocks ![]() Code: // Function modified to accept tag attributes! Textmate Bundle Command Code: heading('${1:heading-text}', '${2:1}', '${3: ${4:id="${5:css-id}" }${6:class="${7:css-class}"}}');${0} Anyone using Textmate (who has extended the 'heading()' html helper as described in this thread) can easily apply the code above to create a new textmate (bundle) command. I simply duplicated the existing 'heading' command (CodeIgniter 1.72 bundle) and applied the code above to the body of the command. Add a tab-trigger of 'heading' and this will allow you to individually tab through each of the elements of the heading tag/function. |