|
I need add an attribute for only a th, but the $helper extend to every TH. I want create a colspan for the 3 th. Ho I can? $thop=array(COLSPAN=>1); $th = array ( $pagination->sortBy('id'), $pagination->sortBy('title'), $pagination->sortBy('created'), "Actions" ); // Generate the pagination sort links echo $html->tableHeaders($th,null,$thop); // Create the table headers with sort links if desired Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
The html Helper does not implement such a behavior. You either have attributes for all th's or for none. So you have a number of possibilities: you either don't use a helper and write the HTML yourself (which shouldn't be hard). Or (if you make use of this helper function very often and changing all instances would be tedious) you write your own function (probably similar to the one in html Helper) that does excactly what you want. Another very ugly possibility would be to change the core html Helper code to do what you want, which I do not recommend. On Dec 14, 6:39 am, "[hidden email]" <[hidden email]> wrote: > I need add an attribute for only a th, but the $helper extend to every > TH. > I want create a colspan for the 3 th. > Ho I can? > > $thop=array(COLSPAN=>1); > $th = array ( > $pagination->sortBy('id'), > $pagination->sortBy('title'), > $pagination->sortBy('created'), > "Actions" > ); // Generate the pagination sort links > echo $html->tableHeaders($th,null,$thop); // Create the table headers > with sort links if desired > > Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
I came accross this same problem 2 wks or so ago and decided I coun't live without that...! So I created my own helper, extending HtmlHelper and implemented the function as follow; [code location="my custom/extended helper"] /** * Returns a row of formatted and named TABLE headers. * * @param array $names Array of tablenames - if a tablename is an array, index 1 should contain th options. * @param array $trOptions HTML options for TR elements. * @param array $thOptions HTML options for TH elements. * @param boolean $return Wheter this method should return a value * @return string */ function tableHeaders($names, $trOptions = null, $thOptions = null, $return = false) { $out = array(); foreach($names as $arg) { if (is_array($arg) && isset($arg[0]) && isset($arg[1])) { // the 2x isset() are pretty useless really... but well for the sake of robustness! $out[] = sprintf($this->tags['tableheader'], $this->parseHtmlOptions(array_merge($thOptions,$arg[1])), $arg[0]); } else { $out[] = sprintf($this->tags['tableheader'], $this->parseHtmlOptions($thOptions), $arg); } } $data = sprintf($this->tags['tablerow'], $this->parseHtmlOptions($trOptions), join(' ', $out)); return $this->output($data, $return); } [/code] then, I use it like this; [code location="any view"] $th = array ( array($pagination->sortBy('weight','Order'), array('width'=>'60px')), $pagination->sortBy('name'), array($pagination->sortBy('status'), array('width'=>'150px')), array('Actions', array('class' => 'actions')), ); $eoHtml->tableHeaders($th); // // note that you could still provide 'global' th options like this; // $eoHtml->tableHeaders($th,null,array('class'=>'whatever')); /// [/code] I don't quite like the fact that names are linked with options, but I really wanted to keep the same signature... plus, it makes a bit of sense to link a specific header name with it's option(s)! so.. the above code will generate a 4 column table headers, column 1 is labeled Order, is sortable (because of the $pagination->sortBy()), and has a fixed width of 60px; column 2 is labeled Name, and is sortable - no other options (the defautl css still applies) column 3 is labeled Status, is sortable (...) and has a fixed width of 150px; and finally column 4 is labeled Actions, and will be generated a class="actions" attribute. Hope this helps... Seb. On Dec 15, 10:22 am, "Falagar" <[hidden email]> wrote: > The html Helper does not implement such a behavior. You either have > attributes for all th's or for none. > > So you have a number of possibilities: you either don't use a helper > and write the HTML yourself (which shouldn't be hard). > > Or (if you make use of this helper function very often and changing all > instances would be tedious) you write your own function (probably > similar to the one in html Helper) that does excactly what you want. > > Another very ugly possibility would be to change the core html Helper > code to do what you want, which I do not recommend. > > On Dec 14, 6:39 am, "[hidden email]" <[hidden email]> wrote: > > > I need add an attribute for only a th, but the $helper extend to every > > TH. > > I want create a colspan for the 3 th. > > Ho I can? > > > $thop=array(COLSPAN=>1); > > $th = array ( > > $pagination->sortBy('id'), > > $pagination->sortBy('title'), > > $pagination->sortBy('created'), > > "Actions" > > ); // Generate the pagination sort links > > echo $html->tableHeaders($th,null,$thop); // Create the table headers > > with sort links if desired > > > Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
This is a really old post but I'm writing this for future reference (if you search cakephp tableheaders colspan this is one of the first hits).
Cake 2.2 implements a way of doing this: El jueves, 14 de diciembre de 2006 21:42:22 UTC-3, Seb escribió:
You received this message because you are subscribed to the Google Groups "CakePHP" group.I came accross this same problem 2 wks or so ago and decided I coun't To post to this group, send email to [hidden email]. To unsubscribe from this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/cake-php?hl=en-US. |
| Powered by Nabble | Edit this page |
