Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » How I can show content in two columns using a template?

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 1921 Views
  • fiord
    Avatar
    Community Member
    79 Posts

    How I can show content in two columns using a template? Link to this post

    Please help me
    How can I show content in two columns using a template?
    I need 2 collumn. how I mast insert <tr> in next code ?

    <table id="ProdList">
    <% control Children %>
    <td>
    <div class="newsDateTitle"><a href="$Link" title="Read more on &quot;{$Title}&quot;">$Title</a></div>
    <div class="newsDateTitle">$Year</div>
    <div class="newsDateTitle">$Color</div>
    </td>
    <% end_control %>
    </table>

  • lekoala
    Avatar
    Community Member
    30 Posts

    Re: How I can show content in two columns using a template? Link to this post

    <table>
    <tr>
    <td>line1 col1</td>
    <td>line1 col2</td>
    </tr>
    <tr>
    <td>line2 col1</td>
    <td>line2 col2</td>
    </tr>
    </table>

    well.. that's the code for a table... so let's imagine that you want a news list on the left and the news details on the right, you could have

    <table id="ProdList">
    <% control Children %>
    <tr>
    <td><div class="newsDateTitle"><a href="$Link" title="Read more on &quot;{$Title}&quot;">$Title</a></div>
    <div class="newsDateTitle">$Year</div>
    <div class="newsDateTitle">$Color</div> </td>
    </tr>
    <tr>
    <td>$Content</td>
    </tr>
    <% end_control %>
    </table>

    is that what you wanted to do?

  • fiord
    Avatar
    Community Member
    79 Posts

    Re: How I can show content in two columns using a template? Link to this post

    no not THIS ((
    in php I write
    <? $i=0; ?>
    <table id="ProdList">
    <% control Children %>
    <? if ($i==0) echo "<tr>";
    ?>
    <td>
    <div class="newsDateTitle"><a href="$Link" title="Read more on &quot;{$Title}&quot;">$Title</a></div>
    <div class="newsDateTitle">$Year</div>
    <div class="newsDateTitle">$Color</div>
    </td>
    <?
    if ($i==1) echo "</tr>";
    if ($i==0){ $i++; }else{ $i=0;}
    ?>
    <% end_control %>
    </table>

    in HTML I wont get next rezult
    <table id="ProdList">

    <tr>
    <td>
    <div class="newsDateTitle"><a href="$Link" title="Read more on &quot;{$Title}&quot;">$Title</a></div>
    <div class="newsDateTitle">$Year</div>
    <div class="newsDateTitle">$Color</div>
    </td>

    <td>
    <div class="newsDateTitle"><a href="$Link" title="Read more on &quot;{$Title}&quot;">$Title</a></div>
    <div class="newsDateTitle">$Year</div>
    <div class="newsDateTitle">$Color</div>
    </td>

    </tr>

    <tr>
    <td>
    <div class="newsDateTitle"><a href="$Link" title="Read more on &quot;{$Title}&quot;">$Title</a></div>
    <div class="newsDateTitle">$Year</div>
    <div class="newsDateTitle">$Color</div>
    </td>

    <td>
    <div class="newsDateTitle"><a href="$Link" title="Read more on &quot;{$Title}&quot;">$Title</a></div>
    <div class="newsDateTitle">$Year</div>
    <div class="newsDateTitle">$Color</div>
    </td>
    </tr>

    </table>

  • Willr
    Avatar
    Forum Moderator
    5482 Posts

    Re: How I can show content in two columns using a template? Link to this post

    Tables?!?!? thats not a solution

    If you want 2 columns whats stopping you doing

    <div class="product">
    Blah
    </div>

    <div class="product">
    Blah
    </div>

    Then just define a width on .product like (50%) and float it left.

  • fiord
    Avatar
    Community Member
    79 Posts

    Re: How I can show content in two columns using a template? Link to this post

    I do not know how to use php code in my .ss file
    How I can make this
    <% control Children %>
    <? if ($i==0) echo "<tr>";
    ?>

  • Willr
    Avatar
    Forum Moderator
    5482 Posts

    Re: How I can show content in two columns using a template? Link to this post

    You cant use PHP in ss templates. You can use $EvenOdd if you only need two.. I think it would be like
    <td>Blah</td>
    <% if EvenOdd = Even %>
    </tr>
    <% end_if %>

  • fiord
    Avatar
    Community Member
    79 Posts

    Re: How I can show content in two columns using a template? Link to this post

    willr, thank you very much

    1921 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.