Status
Not open for further replies.

Chris2k

Banned
Banned
901
2009
17
0
Hi,

ive made a news mod(workin great) 1 prob, it wont show me form in admin panel, heres my code:

Code:
    <?php
    /*BEGIN_INFO
    News mod by Chris2009.
    END_INFO*/
    if(!defined("WCDDL_GUTS"))
    exit;

    $modEnabled = true; //Change to false if don't use
    
    if($modEnabled) {  //start of $modenabled

    $add = array("news" => "News",);

    $core->admin_links = array_merge($core->admin_links, $add);

     function news() {
    
    global $core;
    
        if ($_POST['post']) 
    {
        //Switch the data to variables.
        $title = $_POST['title'];
    }
        $html .= '<form name="post-news" method="POST">
        </form>
        <hr />';
        return $html;
        }
    } //end 
    $core->attachHook("adminFunctions","news");
    ?>

any help????????
 
13 comments
PHP:
<?php
    /*BEGIN_INFO
    News mod by Chris2009.
    END_INFO*/
    if(!defined("WCDDL_GUTS"))
    exit;

    $modEnabled = true; //Change to false if don't use
    if($modEnabled) {  //start of $modenabled
    $add = array("news" => "News");
    $core->admin_links = array_merge($core->admin_links, $add);
    function news() {
     global $core;
        if (!isset($_POST['add_news'])) 
    {
        //Switch the data to variables.
        $html = '<table width="100%" border="0">
        <form name="post-news" action="" method="POST">
        <tr><td align="center" valign="top">Title: </td>
        <td align="left"><input name="title" type="text" size="50" /></td></tr>
        <tr><td align="center" valign="top">Post: </td>
        <td align="left"><textarea name="post" cols="95" rows="25"></textarea></td></tr>
        <tr><td align="center" valign="top" colspan="2"><input type="submit" value="Add News" name="add_news"/></td></tr>
        </form>
        </table>';
      }
      else
      {
      $title = $_POST['title'];
      $post = $_POST['post'];
      //BLA BLA insert Bla Bla
      $html = "NEWS added";
      }
        echo $html;
        }
     if($_GET['go']=='news') $core->attachHook("adminFunctions","news");
    } //end 
    
?>
 
well i think i got it as tried my scrtipt, modified nd now working.

now i need to no can i add my templateVar to my mod or wud i need to make an sepe rate wcddl file|?

or casn i add da admin link to funcs.php????
 
if i understand you want to print the news.

that can be done in same mod.

PHP:
<?php
    /*BEGIN_INFO
    News mod by Chris2009.
    END_INFO*/
    if(!defined("WCDDL_GUTS"))
    exit;

    $modEnabled = true; //Change to false if don't use
    if($modEnabled) {  //start of $modenabled
    $add = array("news" => "News");
    $core->admin_links = array_merge($core->admin_links, $add);
    function news() {
     global $core;
        if (!isset($_POST['add_news'])) 
    {
        //Switch the data to variables.
        $html = '<table width="100%" border="0">
        <form name="post-news" action="" method="POST">
        <tr><td align="center" valign="top">Title: </td>
        <td align="left"><input name="title" type="text" size="50" /></td></tr>
        <tr><td align="center" valign="top">Post: </td>
        <td align="left"><textarea name="post" cols="95" rows="25"></textarea></td></tr>
        <tr><td align="center" valign="top" colspan="2"><input type="submit" value="Add News" name="add_news"/></td></tr>
        </form>
        </table><br />';
      }
      else
      {
      $title = $_POST['title'];
      $post = $_POST['post'];
      //BLA BLA insert Bla Bla
      $html = "NEWS added";
      }
     echo $html;
        }
     if($_GET['go']=='news') $core->attachHook("adminFunctions","news");
     
     $getnews = ("SELECT * from news limit0,5");
     while($gotnews = mysql_fetch_array($getnews)) {
    $outputt = $gotnews['title'].'<br />'.$gotnews['post'];
    }
    $core->setTemplateVar("MODNAME", $outputt); 
    
    } //end mod enable
    
?>
 
Last edited:
here is my code to display it:

PHP:
    //Now add to a templateVar.
        $getnews = mysql_query("SELECT * FROM wcddl_news");
        
        while($row = mysql_fetch_assoc($getnews)) 
        {
            //get data
            $id = $row['id'];
            $title = $row['title'];
            $body = $row['body'];
            $date = $row['dat'];
            
        $nd = "<div class='search-btn'>

        <font color='White'>$date</font>
        
        </div><br><br>";
        
        $nd = nl2br ($title);
        
        $nd = nl2br ($body);
            
        }
        
        $core->setTemplateVar("newsdisplay", $nd);

dunno y it isnt workin?
 
concatenate $nd

$nd = "<div class='search-btn'>

<font color='White'>
$date</font>

</div><br><br>"
;

$nd .= nl2br ($title);

$nd .= nl2br ($body);
 
here is my full news mod:

PHP:
    <?php
    /*BEGIN_INFO
    News mod by Chris2009.
    END_INFO*/
    if(!defined("WCDDL_GUTS"))
    exit;

    $modEnabled = true; //Change to false if don't use
    
    if($modEnabled) {  //start of $modenabled
    
    $add = array("news" => "News");
    
    $core->admin_links = array_merge($core->admin_links, $add);
    
    function news() {
    
    global $core;
    
    if (!isset($_POST['post'])) 
    {
        //Show table/form in ACP.
        $htmlnews = "<form name='post-news' method='POST'>
        
        <p>News Title:</p>

        <input name='title' type='text' width='380' />

        <p>News Body:</p>
  
        <textarea name='body' cols='60' rows='10'></textarea>
  
        <br><input type='submit' name='post' value='Post this news..' />
        </form><hr /> <br>";
        }
        else {

            //Switch the data to variables.
            $title = $_POST['title'];
            $body = $_POST['body'];
            $date = date('d m Y');
        
            //Insert to DB.
            $insert = mysql_query("INSERT INTO wcddl_news VALUES ('','".mysql_real_escape_string($title)."','".mysql_real_escape_string($body)."','".mysql_real_escape_string($date)."')");
            
            $htmlnews = "Your news has been posted.";
        }
        echo $htmlnews; //Always echo mods.
        } //function end.
    if($_GET['go']=='news') $core->attachHook("adminFunctions","news"); //Add ACP link.
    
        //Now add to a templateVar.
        $getnews = mysql_query("SELECT * FROM wcddl_news");
        
        while($row = mysql_fetch_assoc($getnews)) 
        {
            //get data
            $id = $row['id'];
            $title = $row['title'];
            $body = $row['body'];
            $date = $row['dat'];
            
        $nd .= "<div class='search-btn'>

        <font color='White'>$date</font>
        
        </div><br><br>";
        
        $nd .= nl2br ($title);
        
        $nd .= nl2br ($body);
            
        }
        
        $core->setTemplateVar("newsdisplay", $nd);  
    } //end  of module.
?>

as u can see the template at the bottom, nothing displays.

any help? + this is how im calling it: <?=$core->templateVar("displaynews")?>

this is right?
 
Cris i can't help much at momment, my pc are total FU*ed

$nd
.= "<div class='search-btn'>

<font color='White'>
$date</font>

</div><br><br>"
;
try this change
$nd = '<div class="search-btn">

<font color="White">'.
$date.'</font>

</div><br><br>'
;
 
Status
Not open for further replies.
Back
Top