Forum Index   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
omorelOffline



Joined: Apr 06, 2004
Posts: 8

Status: Offline
Post   Posted: Apr 20, 2004 - 09:33 AM Reply with quote Back to top

Hi,

I'm developping a new module for pn and I am using the new Xanthia module for pn version 0.726-1.

I would like to do this :

-> main fonction :
-> fonction "a" :
-> render a template
-> fonction "b" :
-> render another template
-> render a third template.

So how could I append the result of one template to another one ? Oh and I would like to be able to call the templates from inside pn and not from another template...
View user's profile Send private message
Chestnut
Site Admin


Joined: Oct 08, 2003
Posts: 1065
Location: Paris - France
Post   Posted: Apr 20, 2004 - 01:25 PM Reply with quote Back to top

The Example mod is your best friend Wink (the pncSimpleStatsX also)

I don't fully understand your list with function but I'll go this way... we will be able to correct things.

Code:

function yourmod_user_main()
{

    // This function renders the main template
   
    //Security
    if (!pnSecAuthAction(0, YOURMOD::', '::', ACCESS_OVERVIEW)) {
        return pnVarPrepHTMLDisplay(_YOURMODNOAUTH);
    }

    // New Render Instance
    $pnRender =& new pnRender('YOURMOD');

    // Template for main
    return $pnRender->fetch('YOURMOD_user_main.htm');
}


Example of applications :
If you want a top menu that will be on all pages, you can do a simple include in your template :

file : yourmod_user_menu.htm
Code:

<br />
<br />
<a href="LINK1">LINK1</a> - <a href="LINK2">LINK2</a>
<br />
<br />


Now to include that in your templates :
yourmod_user_main :

Code:

<!--[include file="yourmod_user_menu.htm"]-->


Voilą for the menu !

Now if you look at function Example_user_view() in the Example mod...
The function fetch all example items :
Code:

    $items = pnModAPIFunc('Example',
                          'user',
                          'getall',
                          array('startnum' => $startnum,
                                'numitems' => pnModGetVar('Example',
                                                          'itemsperpage')));

then, (after one or 2 manipulations), input in a template each of these items and all this will be in an array :

Code:

$exampleitems = array();
foreach ($items as $item) {
    $pnRender->assign($item);
    $exampleitems[] = $pnRender->fetch('example_user_row_read.htm', $item['tid']);
}


Now the array var $exampleitems have a template for each item.

Next... the array is sended to another template, the view page :
Code:

    // ....
    $pnRender->assign('items', $exampleitems);
    return $pnRender->fetch('example_user_view.htm');
}


In the 'example_user_view.htm', there is a var 'items' that contains a template ('example_user_row_read.htm') for each items.

example_user_view.htm :
Code:

<!--[include file="example_user_menu.htm"]-->
<br />
<br />

<!--[* Loop through the items and display them   *]-->
<!--[foreach item=item from=$items]-->
<!--[$item]-->
<!--[/foreach]-->


This loop and most explicitly, this line :
Code:

<!--[$item]-->

is our example_user_read.htm template that contains one item of the list. The loop make it so we show all items of the list.

See the example mod and the pncSimpleStats (where I wrote LOTS of crappy comments) for other examples like this.

Hope this helps a bit ! At least for a start !

_________________
Chestnut ! Cool
Administrator
PNConcept.com
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
Chestnut
Site Admin


Joined: Oct 08, 2003
Posts: 1065
Location: Paris - France
Post   Posted: Apr 20, 2004 - 01:27 PM Reply with quote Back to top

Damn... the pncSimpleStats was made using the pnHTML, not the pnRender. the pncSimpleStatsX is made for the pnRender but I didn't wrote the comments in it...

I must not forget to change that.

_________________
Chestnut ! Cool
Administrator
PNConcept.com
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
omorelOffline



Joined: Apr 06, 2004
Posts: 8

Status: Offline
Post   Posted: Apr 20, 2004 - 02:37 PM Reply with quote Back to top

Ok, i'll show you what I've done... and maybe you'll be able to help me a bit (no, I'm not too lazy to read what you wrote, I have read it).

so :


it's based on a plugin model. this is a plugin.

Code:

function pnsCommentarium_userapi_reviews_short_display($args)
{
    extract($args);

    if (!pnModAvailable('Reviews')) {
        return ;
    }

    $dbconn          = &pnDBGetConn(true);
    $pntable          = &pnDBGetTables();
   
    $reviews          = &$pntable['reviews'];
    $reviews_column    = &$pntable['reviews_column'];
   
    $sql =       "SELECT      $reviews_column[title],
                             $reviews_column[score],
                     $reviews_column[id]
             FROM       $reviews
                  WHERE       $reviews_column[reviewer]='" . $uname."'
             ORDER BY    $reviews_column[id]";
   
    echo $sql;
   
    $results = $dbconn->Execute($sql);
   
    for (; !$results->EOF; $results->MoveNext()) {
      list($pn_title, $pn_score, $pn_id) = $results->fields;
      $items[] = array(   'pn_title'           => $pn_title,
                      'pn_score'    => $pn_score,
                      'pn_id'      => $pn_id);
   }
   
    $pnRender->assign('items', $items);
    $pnRender->assign('module', 'Reviews');
   
   return $pnRender->fetch('pnsCommentarium_reviews_display_short.htm');

}


this is the main fonction.

Code:


function pnsCommentarium_user_main(){

   if (!pnSecAuthAction(0, 'pnsCommentarium::', '::', ACCESS_OVERVIEW)) {
      return pnVarPrepHTMLDisplay(_EXAMPLENOAUTH);
   }

   $pnRender =& new pnRender('pnsCommentarium');

   $user          = 'omorel';
   $view          = 1;
   $new_window      = 0;
   $target              = 'omorel';
   $modules       = array (0    => array (   'module'    =>    'reviews',
                                 'checked'    =>   1));
         

   foreach ($modules as $module) {
       
      $execok = true;

      pnModAPILoad('pnsCommentarium', 'user');

       if ($module['checked'] == 1) {       
            
         $result = pnModAPIFunc(      'pnsCommentarium',
                                                   'user',   
                              'fileexist',
                                                                 array('file' => $module['module']));
         
         
          if ($result == true) {
              require_once('modules/pnsCommentarium/plugins/'.pnVarPrepForOs($module['module']).'.php');
           }
           else {
              $execok = false;
           }
                      

         if ($view == 1) {

              if ($execok == true)
                  $moddisplay[] = pnModAPIFunc(   'pnsCommentarium',
                                              'user',
                                                            $module['module'] . '_short_display',
                                                            array(   'uname'      => $target,
                                                    'pnRender'   => $pnRender));
         }
         else {
         
            if ($execok == true)
                  pnModAPIFunc(      'pnsCommentarium',
                                       'user',
                                     $module['module'] . '_long_display',
                                     array(   'uname'   => $target));
                                  
         }
      }
   }

   return $pnRender->fetch('pnsCommentarium_reviews_short_display.htm');
}



but it only displays pnsCommentarium_reviews_short_display.html ... Sad

Please... help me... [/code]
View user's profile Send private message
Chestnut
Site Admin


Joined: Oct 08, 2003
Posts: 1065
Location: Paris - France
Post   Posted: Apr 20, 2004 - 03:08 PM Reply with quote Back to top

Check the file... I think it would be a better start...

Always remember that the GUI (interface, rendering, the display is in the user functions)...

userapi are function that returns a value like a sql result, etc...

Unless the inevitable I guess.

Note also that the pnModAPILoad is done once... I moved it up.

_________________
Chestnut ! Cool
Administrator
PNConcept.com
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
omorelOffline



Joined: Apr 06, 2004
Posts: 8

Status: Offline
Post   Posted: Apr 21, 2004 - 11:08 AM Reply with quote Back to top

Ok, there I found my "mistake" or what I misunderstood...

I would like to develop a module which plugins could add their one GUI code... how would it be possible ?

PS : sorry for the silly questions, new to pn...
View user's profile Send private message
Chestnut
Site Admin


Joined: Oct 08, 2003
Posts: 1065
Location: Paris - France
Post   Posted: Apr 21, 2004 - 11:45 AM Reply with quote Back to top

The file I gave you contains what you ask.

This part :
Code:

     $items = pnModAPIFunc('pnsCommentarium',
                           'user',
                           $module['module'] . '_short_display',
                           array('uname' => $target));


fetches the items (array) you need...
This part :
Code:

$pnRender->assign('item',   $item);
$pnRender->assign('module', $module['module']); // Not Reviews sorry

$moditems[] = $pnRender->fetch('pnsCommentarium_'.$module['module'].'_display_short.htm);


Assign the items to the template of the plugin you want :
this : pnsCommentarium_'.$module['module'].'_display_short.htm
Is your display for the plugin.

_________________
Chestnut ! Cool
Administrator
PNConcept.com
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits
DarkMindZ