Using divs instead of table columns on home page

Discussion in 'Customizations' started by freeze2, Aug 18, 2009.

  1. freeze2 Customer

    I've been working on formatting the home page of my classifieds without using the table columns. This way each category with subcategories can float in their own div...I'm finding this allows a cleaner look for what I'm after. I made the following change to the code on the home.tpl and was hoping someone could tell me if this is correct or needs some changes. It does look fine on the site.

    HTML:
    <table class="main" width="100%">
    	<tr>
    		<th>{$smarty.const.LANG_BROWSE_CATEGORY}</th>
    	</tr>
    	<tr>
    		<td valign="top">
    			{section name=tr loop=$data step=$cols}
    				{section name=td start=$smarty.section.tr.index loop=$smarty.section.tr.index+$cols}
    					<div class="categoryhome">
    						{if $data[td]<>""}
    							{$data[td].start_link}<img src="{$data[td].image}" border="0" alt="{$data[td].name}" /></a> 
    							{$data[td].start_link}<strong>{$data[td].name}</strong></a>
    							{if $data[td].total <> ''}
    							({$data[td].total})
    							{/if}
    							{$data[td].subcats}
    							{$data[td].description}
    						{/if}
    					</div>
    				{/section}
    			{/section}
    		</td>
    	</tr>
    </table>
  2. Eric Barnes Guest

    It looks correct to me. Just from glancing at it you may want to put the categoryhome div inside the if($data[td']) just incase it is blank. But I think that is required.
  3. freeze2 Customer

    Thanks much!
  4. seymourjames All Hands On Deck

    The problem is does it look fine on various browsers. Does it validate as XHTML transitional The W3C Markup Validation Service. Posting a link would help to get more feedback.
  5. freeze2 Customer

  6. seymourjames All Hands On Deck

    Looks good on Firefox and safari. It validates too XHTML transitional.
  7. freeze2 Customer

    Thanks...I hadn't tested on Safari.

    I did have to add a "display: inline" to the main div to fix an ie6 float problem...but other than that I'm pleased with the outcome. One problem with using floating divs for the category layout is that you have to watch the order in which they are placed....you have to make sure to keep the categories with the most subcategories to the left to have them fall into place nicely...
  8. Hey Me Customer

    Would be nice if added to the script by default or make it possible to edit from templates, not healthy to modify core files, it makes upgrades more complicated ..
  9. Blair Administrator

    Typically, you don't have to overwrite files located in the templates folder during an upgrade.
  10. seymourjames All Hands On Deck

    It is not a core file. He is putting this in a template folder - home.tpl . By all accounts you should copy the default template folder when you first install and call it something else. You then modify this new template folder with peace of mind. The documentation on how templates work is pretty clear. If a file exists in your new template folder it will be used but if it does not exist it will default to the DEFAULT. This way if you make a real hash of things you simply delete your version of the template file and it will pick up the default and bring you back to normal.
  11. Hey Me Customer

    OK sorry, because there is a case where you have to edit some Categories.php file in order to display categories in a certain way. Is that possible through templates?
  12. Lhotch curmudgeon

    You should be able to handle this at the template level. I know when looking at index.php it collects the category details and send them off to the template home.tpl as an array.

    The template home.tpl loops over the array building table rows and cells so you would need to alter that to create divs instead of rows and cells.
  13. guillopuig Customer

    Hey Freeze, which part of the Home.tpl file did you replace with the code below?




  14. freeze2 Customer

    I believe I replaced the code between the <table class="main" width="100%"></table>
  15. michop Customer



    This works great! but how can I put the categories in 3 columns instedad of 1?
  16. Lhotch curmudgeon

    The 68C documentation has a wealth of information.....

    Main Settings - 68 Classifieds
  17. michop Customer

    I think this is not covered in the documentation... when I made those changes in the home.tpl file, all categories appears in a single column.
  18. Lhotch curmudgeon

    Normally the number of columns is controlled by your settings in admin. When you start hacking them up you run the risk of circumventing built in behaviour.
  19. freeze2 Customer

    Take a look at your css and make sure that you set a width of each div that will allow for 3 columns and then make sure they float: left.

    That should do it...
  20. michop Customer

    I cannot find that information in the css file. Can you help me with this?

    Thank you for your patience.

Share This Page