News:

SMF 2.1.6 has been released! Take it for a spin! Read more.

Main Menu

change layout of child boards

Started by mariolone, January 05, 2008, 06:44:16 AM

Previous topic - Next topic

mariolone

Hello,

I would like to change the layout of child boards index in this way:

create a table of 2 or 3 columns where the child boards are listed (for 10 or 15 lines), in this way:





child board 1child board 3child board 5
child board 2child board 4child board 6
etc.etc.
etc.



How and where to change the code?

Thank you very much

Rumbaar

I think that would be in the BoardIndex.template.php, you can take a look at how DilberMC theme does it.
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

mariolone

yes, thank you, Dilber MC does exactly what I need.

But it's hard for me to make the modifications. If you can indicate me where to copy the code in Dilber MC (boardindex.template.php) and where to paste it in default theme, you would be very kind!

Thank you in advance

Rumbaar

You can try and copy the whole BoardIndex.template.php (be sure to backup your original version) to your custom theme and see how that goes.

If that doesn't help I'll look to download that theme and point out the part.  If you are working on the CORE theme, I recommend creating a new theme based on that theme and working with that theme.
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

mariolone

Hi Rumbaar,

I tried to copy the part of the code I needed but it didn't work. Probably it's a problem of "classes" that are not included in default theme (but in DilberMC yes).

Here's the part of "Default" theme:

Quote// Show the "Child Boards: ". (there's a link_children but we're going to bold the new ones...)
            if (!empty($board['children']))
            {
               // Sort the links into an array with new boards bold so it can be imploded.
               $children = array();
               /* Each child in each board's children has:
                     id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */
               foreach ($board['children'] as $child)
               {
                     $child['link'] = '<a href="' . $child['href'] . '" title="' . ($child['new'] ? $txt[333] : $txt[334]) . ' (' . $txt[330] . ': ' . $child['topics'] . ', ' . $txt[21] . ': ' . $child['posts'] . ')">' . $child['name'] . '</a>';
                     $children[] = $child['new'] ? '<b>' . $child['link'] . '</b>' : $child['link'];
               }

               echo '
         <tr>
            <td colspan="3" class="windowbg', !empty($settings['seperate_sticky_lock']) ? '3' : '', '">
               <span class="smalltext"><b>', $txt['parent_boards'], '</b>: ', implode(', ', $children), '</span>
            </td>
         </tr>';
            }
         }
         echo '
      </table>';
      }
      echo '
   </div>';

Here's the part of "DilberMC" theme:

Quote// Show the "Child Boards: ". (there's a link_children but we're going to bold the new ones...)
            if (!empty($board['children']))
            {
               // Sort the links into an array with new boards bold so it can be imploded.
               $children = array();
               /* Each child in each board's children has:
                     id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */
               foreach ($board['children'] as $child)
               {
                     $child['link'] = '<a href="' . $child['href'] . '" title="' . ($child['new'] ? $txt[333] : $txt[334]) . ' (' . $txt[330] . ': ' . $child['topics'] . ', ' . $txt[21] . ': ' . $child['posts'] . ')">' . $child['name'] . '</a>';
                     $children[] = $child['new'] ? '<img style="margin-right:5px;" src="' . $settings['images_url'] . '/' . $settings['theme_main_color'] . '/onk.gif" alt="' . $txt[333] . '"/><b>' . $child['link'] . '</b>' : '<img style="margin-right:5px;" src="' . $settings['images_url'] . '/' . $settings['theme_main_color'] . '/offk.gif" alt="' . $txt[334] . '"/>' . $child['link'];                     
               }

               echo '
               <table style="float:right; margin-top: 15px;" width="100%" cellspacing="0" cellpadding="3" border="0">
                  <tr>
                     <td class="middletext" valign="middle" align="center" width="30%">
                        <b>', $txt['parent_boards'], ':</b>
                     ';

               $child_counter = 0;
               
               if(empty($settings['child_boards_rows']))
               {
                  echo '   
                     </td>
                     <td class="middletext" valign="top">';
                        
                        for(; $child_counter < ceil(count($children)/2); $child_counter++)
                              echo $children[$child_counter], '<br/>';
               }
               
               echo '
                     </td>
                     <td class="middletext" valign="top">';   
                        for(; $child_counter < count($children); $child_counter++)
                              echo $children[$child_counter], '<br/>';
               echo '
                     </td>
                  </tr>
               </table>';
            }

How can I change my Default theme?

Thank you very much!

Rumbaar

Did you try replacing the whole
// Show the "Child Boards: ". (there's a link_children but we're going to bold the new ones...)
            if (!empty($board['children']))
            {
               // Sort the links into an array with new boards bold so it can be imploded.
               $children = array();
               /* Each child in each board's children has:
                     id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */
               foreach ($board['children'] as $child)
               {
                     $child['link'] = '<a href="' . $child['href'] . '" title="' . ($child['new'] ? $txt[333] : $txt[334]) . ' (' . $txt[330] . ': ' . $child['topics'] . ', ' . $txt[21] . ': ' . $child['posts'] . ')">' . $child['name'] . '</a>';
                     $children[] = $child['new'] ? '<b>' . $child['link'] . '</b>' : $child['link'];
               }

               echo '
         <tr>
            <td colspan="3" class="windowbg', !empty($settings['seperate_sticky_lock']) ? '3' : '', '">
               <span class="smalltext"><b>', $txt['parent_boards'], '</b>: ', implode(', ', $children), '</span>
            </td>
         </tr>';
            }
         }
         echo '
      </table>';
      }

with:
// Show the "Child Boards: ". (there's a link_children but we're going to bold the new ones...)
            if (!empty($board['children']))
            {
               // Sort the links into an array with new boards bold so it can be imploded.
               $children = array();
               /* Each child in each board's children has:
                     id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */
               foreach ($board['children'] as $child)
               {
                     $child['link'] = '<a href="' . $child['href'] . '" title="' . ($child['new'] ? $txt[333] : $txt[334]) . ' (' . $txt[330] . ': ' . $child['topics'] . ', ' . $txt[21] . ': ' . $child['posts'] . ')">' . $child['name'] . '</a>';
                     $children[] = $child['new'] ? '<b>' . $child['link'] . '</b>' : $child['link'];                 
               }

               echo '
               <table style="float:right; margin-top: 15px;" width="100%" cellspacing="0" cellpadding="3" border="0">
                  <tr>
                     <td class="middletext" valign="middle" align="center" width="30%">
                        <b>', $txt['parent_boards'], ':</b>
                     ';

               $child_counter = 0;
               
               if(empty($settings['child_boards_rows']))
               {
                  echo '   
                     </td>
                     <td class="middletext" valign="top">';
                       
                        for(; $child_counter < ceil(count($children)/2); $child_counter++)
                              echo $children[$child_counter], '<br/>';
               }
               
               echo '
                     </td>
                     <td class="middletext" valign="top">';   
                        for(; $child_counter < count($children); $child_counter++)
                              echo $children[$child_counter], '<br/>';
               echo '
                     </td>
                  </tr>
               </table>';
            }
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

mariolone

Unfortunatly, an error of syntax occurs.

Rumbaar

Did you copy and paste exactly and only what I posted?
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

immaturity

mariolone, I also had syntax errors when trying to use only the child boards columns section from dilbermc theme.
what I had to do to is...

open Dilbermc's boardindex.template.php and manually change/add any mods you have already installed (if you have no mods installed on your forum, then just use dilbermc's entire boardindex as-is)

It doesn't seem to use any style classes that are different from the default, so changes you have made in your style.css will continue to work.

There are slight differences between the default and the dilber themes, but it is easier to edit the dilbermc theme's boardindex.template.php file directly than it is to take pieces from it and edit the default's file.
Access your inner Immaturity at the Parental Playground.

Deaks

mariolone im going through old topics do you still need this fixed? or can we mark this topic as solved
~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

mariolone

Hi RunicWarrior,

I have not already tried to edit the Dilbermc's boardindex.template.php as suggested by "immaturity", but I will do it by the end of this week.

I will notify success or problems as soon as possible. I hope to tell you the problem is fixed  ;)

Thank you

Deaks

~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

mariolone

I can't solve it  :-\

Instead of trying to copy and paste the DilberMC code into the Default Theme (probably, I wrong something because I see sintax errors), how to simple create a table for Child Boards as in Dilber MC but in Default theme?

Thanks

Rumbaar

Have you tried to just copy the BoardIndex.template.php file from DilberMC into your current custom theme and see how it goes.
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

mariolone

hi rumbaar,

yes I tried but it looks not so nice. Child boards fonts are bigger than before the copy of the file. I would like to view the list of child boards in 3-4 floating columns with the same font size as in default theme. How to do that?

Thank you

Rumbaar

Well I would assume the file uses defined styles and would still be controlled by your style.css.  So you can set the font size, etc to whatever you want it to be.

3-4 columns will take some coding, I tried to play with the code at one point in resent weeks and wasn't able to get it to correct display beyond 2 columns.

Best of luck find that solution.
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

Advertisement: