werushka Posted February 13, 2009 Share Posted February 13, 2009 Hi I am new to PHP i have code that I am trying to edit, the code is below. function phptemplate_views_view_table ($view, $nodes, $type) { $fields = _views_get_fields(); foreach ($nodes as $node) { $row = array(); $row2 = array(); foreach ($view->field as $field) { if ($fields[$field['id']]['visible'] !== FALSE) { switch ($field['field']) { case 'pic'; $cell['data'] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view); $cell['class'] = "view-field ". views_css_safe('view-field-'. $field['queryname']); $row[] = $cell; break; case 'title'; $cell['data'] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view); $cell['class'] = "view-field ". views_css_safe('view-field-'. $field['queryname']); $row[] = $cell; break; case 'totalcount'; $cell['data'] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view); $cell['class'] = "view-field ". views_css_safe('view-field-'. $field['queryname']); $row[] = $cell; break; case 'name'; $cell['data'] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view); $cell['class'] = "view-field ". views_css_safe('view-field-'. $field['queryname']); $row2[] = $cell; break; case 'subscribe'; $cell['data'] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view); $cell['class'] = "view-field ". views_css_safe('view-field-'. $field['queryname']); $row2[] = $cell; break; } } } $rows[] = $row; $rows[] = $row2; } return theme('table', $view->table_header, $rows); } What I want to do is group row and row2 so that it sits inside div class=rowgroup and give div id tags to "pic","title","totalcount","name", "subscribe" If i can understand this it would be great for me so I can start to theme by trial error. Thanks Link to comment https://forums.phpfreaks.com/topic/145026-insert-div-tag-in-a-function/ Share on other sites More sharing options...
Q695 Posted February 13, 2009 Share Posted February 13, 2009 You use div tags in functions just like HTML. Link to comment https://forums.phpfreaks.com/topic/145026-insert-div-tag-in-a-function/#findComment-761082 Share on other sites More sharing options...
werushka Posted February 13, 2009 Author Share Posted February 13, 2009 thanks for your reply like as far as i learned I know how to output div tag in a code like <?php echo "<div="test"></div>" ?> as follows but in here I can not use echo or print. Link to comment https://forums.phpfreaks.com/topic/145026-insert-div-tag-in-a-function/#findComment-761098 Share on other sites More sharing options...
Q695 Posted February 13, 2009 Share Posted February 13, 2009 If nothing is in it, close the php before you use the fiv tag, and it will work just like html. Link to comment https://forums.phpfreaks.com/topic/145026-insert-div-tag-in-a-function/#findComment-761100 Share on other sites More sharing options...
werushka Posted February 13, 2009 Author Share Posted February 13, 2009 thanks anyway I tried it but no luck in my side Link to comment https://forums.phpfreaks.com/topic/145026-insert-div-tag-in-a-function/#findComment-761139 Share on other sites More sharing options...
Q695 Posted February 13, 2009 Share Posted February 13, 2009 you're also using the wrong quotes, since '=". Link to comment https://forums.phpfreaks.com/topic/145026-insert-div-tag-in-a-function/#findComment-761418 Share on other sites More sharing options...
Boo-urns Posted February 13, 2009 Share Posted February 13, 2009 Is the " $cell['class']" is that your div class? What does the views_css_safe function do? I'd check all of those functions out and see where the divs and everything are produced. Link to comment https://forums.phpfreaks.com/topic/145026-insert-div-tag-in-a-function/#findComment-761443 Share on other sites More sharing options...
Q695 Posted February 13, 2009 Share Posted February 13, 2009 Try this to next values within quotes on 3 or more levels: " <?php echo "$cell['class']"?>" Link to comment https://forums.phpfreaks.com/topic/145026-insert-div-tag-in-a-function/#findComment-761646 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.