Results 1 to 8 of 8

Thread: Trying to set up a new block

  1. #1
    Join Date
    Sep 2006
    Posts
    20

    Default Trying to set up a new block

    Hello! Question from a "idiot" here...

    I am trying to create a block to display text that simply announces a drawing winner. I can't get this block to show up on the home page. This is what I've done so far:

    Created block.drawing_winners.html (uploaded to themes/kosmos/blocks)
    HTML Code:
     <table width="197" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td style="background-image: url(<%$tpl_base%>/images/template_23.gif);" class="head">&nbsp;Latest Drawing Winner</td>
                    <td width="31"><img src="<%$tpl_base%>/images/template_24.gif" alt="" /></td>
                  </tr>
                </table>
                <table width="197" border="0" cellpadding="5" cellspacing="0" class="panel-bg">
                  <tr>
                    <td>        
                      <br>
    					<b>Congratulations to<br>
    					<font color="#0000FF">Burinvit A. of<br>
    					Bangkok, Thailand!</font></b></p>
    					<p>He is the lucky winner of our August 2006 Monthly Prize 
    					Drawing for a $50.00 Amazon.com<br>
    					Gift Certificate.</p>
    					<p><b>September 2006 Prize:</b><br>
    					$50.00 Amazon.com<br>
    					Gift Certificate</p>
    					<font size="1"><a href="page.php?id=winners">See more 
    					winners!</a></font><br />
                      <br />
                    </td>
                   </tr>
                 </table>
    Next I created block.drawing_winners.php (uploaded to /blocks/):
    PHP Code:
    <?php

    /**
     *
     * INDEXU
     * Copyright(C), Nicecoder, 2000-2006, All Rights Reserved.
     *
     * INDEXU(tm) is protected by Indonesia and International copyright laws.
     * Unauthorized use or distribution of INDEXU(tm) is strictly prohibited,
     * violators will be prosecuted. To obtain a license for using INDEXU(tm),
     * please register at Nicecoder home page at http://www.nicecoder.com
     *
     * Author:
     *    Dody Rachmat Wicaksono (dody@nicecoder.com)
     *    M. Zuber (zubby@nicecoder.com)
     *
     */

    function block_drawing_winners($params) {

      if (!
    $params['template']) {
        
    $params['template'] = 'block.drawing_winners.html';
      }

      
    $tpl = new Template;

      
    $tpl->display("blocks/" $params['template']);
    }

    ?>
    Lastly, I added the following code to my index.html (using kosmos theme) at the point where I want it to show up (left side).
    HTML Code:
    <%block_drawing_winners%>
              <br />
    What do I do next?

    Thank you!
    Angie

    Thank you!

  2. #2
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    jsut paste what you have in block.drawing_winners.html

    directly to your index.html page, no need to use a block. or, you could just use :

    <%include file='themes/kosmos/blocks/block.drawing_winners.html'%>
    Main IndexU sites : | Campsite Directory | Tourist Guide | Places2B | AfterDirectory <-- Half price submission using coupon DP50 (from just $11 premium, and $10 basic permanent )

  3. #3
    Join Date
    Sep 2006
    Posts
    20

    Default

    I thought about doing that, but it just seemed too easy!

    (Can you tell I like to make things harder for myself?? HAHA!)

    Thanks so much, inspireme!

  4. #4
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    well, your just running a php script and asking it to inser the html, so you may as well just insert the html.

    use the include code i posted if you want it on multiple pages, eg. maybe the browse page as well.
    Main IndexU sites : | Campsite Directory | Tourist Guide | Places2B | AfterDirectory <-- Half price submission using coupon DP50 (from just $11 premium, and $10 basic permanent )

  5. #5
    Join Date
    Sep 2006
    Posts
    20

    Default

    I tried using the include code but got a smarty error. Rather than spend more time trying to figure it out, I just pasted the code from the block page as you suggested and it works great!

  6. #6
    Join Date
    May 2004
    Location
    New Zealand
    Posts
    600

    Default

    I played around with some examples (Inspireme's Adsense one)
    If you use this in your blocks.drawing_winners.php file, it should work, it does in 5.3

    function block_drawing_winners($params) {
    $tpl = new Template;
    if (!$params['template']) {
    $params['template'] = 'block.drawing_winners.html';
    }
    $tpl->display('blocks/'.$params['template'], 0);
    }

    Cheers Ezy

  7. #7
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,732

    Default

    Create a new block, if you need to run php codes, like fetching database. But if you just want to split insert html codes, just use smarty with include command.

  8. #8
    Join Date
    Sep 2006
    Posts
    20

    Default

    Thanks for the additional tips Ezy & Dody!

Similar Threads

  1. block and variables
    By inspireme in forum v5.x
    Replies: 1
    Last Post: 04-17-2006, 03:51 PM
  2. MOD toprated block
    By esm in forum Blocks and Modification
    Replies: 0
    Last Post: 04-14-2006, 07:57 AM
  3. Add custom block
    By snoezel in forum Tutorials, Hints & Tips
    Replies: 6
    Last Post: 01-17-2006, 02:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •