to previous topic Print topic to next topic

 Root :: Developments :: Modules :: advProfile v4bJournal plugin
 Moderated by:
 
  Bottom  advProfile v4bJournal plugin
MACscr Posted: 12.09.2005, 02:04
Plumber
Plumber


registered: Jan 11, 2005
Posts: 147

Status:  offline
last visit: 19.04.06
I have tried making a stab at getting one to work,but i havent had any luck. Here is the code i have so far.

Code
  1. function smarty_function_last10v4bjournal($params, &$smarty)
  2. {
  3.  
  4.     if (!pnSecAuthAction(0, 'advProfile::', 'Plugin::last10v4bjournal.php', ACCESS_READ)) {
  5.         return false;
  6.     }
  7.  
  8.     extract($params);
  9.     unset($params);
  10.  
  11.     if (!isset($uname) || empty($uname)) {
  12.         echo "uname";
  13.         return false;
  14.     }
  15.  
  16.     if (!isset($template) || empty($template)) {
  17.         $template = pnModGetVar('advProfile', 'template');
  18.     }
  19.  
  20.     $dbconn  =& pnDBGetConn(true);
  21.     $pntable =& pnDBGetTables();
  22.  
  23.     $sql="SELECT jjo_id, jjo_title, jjo_lu_date from ".pnConfigGetVar('prefix')."_v4b_journal_journal
  24.     WHERE jjo_owner_uid='$uid' AND jjo_permission!=0 ORDER BY jjo_lu_date desc";
  25.  
  26.     $result = $dbconn->SelectLimit($sql, 10, 0);
  27.  
  28.     if ($dbconn->ErrorNo() != 0) {
  29.         echo $dbconn->ErrorMsg();
  30.         return false;
  31.     }
  32.  
  33.     $last10v4bjournal = array();
  34.  
  35.     for(; !$result->EOF; $result->MoveNext()) {
  36.         list($jjo_id, $jjo_title, $jjo_lu_date) = $result->fields;
  37.  
  38.         $last10v4bjournal[] = array('jjo_id'   => $jjo_id,
  39.                               'jjo_title'   => $jjo_title,
  40.                               'jjo_lu_date' => $jjo_lu_date);
  41.     }
  42.  
  43.     $result->Close();
  44.  
  45.     $pnRender =& new pnRender('advProfile');
  46.  
  47.     $pnRender->Assign('last10v4bjournal', $last10v4bjournal);
  48.  
  49.     $template = $template."/advProfile_plugin_v4bjournal.tpl";
  50.  
  51.     if (!$pnRender->template_exists(pnVarPrepForOS($template))) {
  52.         echo "notexists";
  53.         return false;
  54.     }
  55.  
  56.     @include_once('modules/advProfile/pnlang/'.pnVarPrepForOS(pnUserGetLang()).'/last10v4bjournal.php');
  57.  
  58.     $tpl = $pnRender->Fetch($template, $uid);
  59.  
  60.     if (isset($assign)) {
  61.         $smarty->assign($assign, $tpl);
  62.     } else {
  63.         return $tpl;
  64.     }
  65.  
  66. }


and here is the template

Code
  1. <table >
  2.   <thead>
  3.     <tr>
  4.       <th >Last 10 Journal Entries</th>
  5.     </tr>
  6.   </thead>
  7.   <tbody>
  8.     <tr>
  9.       <td >
  10.         <!--[if $last10v4bjournal]-->
  11.           <ul class="linklist">
  12.             <!--[section name="last10v4bjournal" loop=$last10v4bjournal]-->
  13.               <li><a class="pn-normal" href="index.php?module=v4bJournal&func=journal_view&id=<!--[$last10v4bjournal[last10v4bjournal].jjo_id]-->&mode=detail" alt="<!--[$last10v4bjournal[last10v4bjournal].jjo_id]-->"><!--[$last10v4bjournal[last10v4bjournal].jjo_title]--></a>";
  14.               </li>
  15.             <!--[/section]-->
  16.           </ul>
  17.         <!--[else]-->
  18.            
  19.         <!--[/if]-->
  20.       </td>
  21.     </tr>
  22.   </tbody>
  23. </table>


And here is the tag i add to the advprofile_user_all.tpl file

Code
  1. <!--[last10v4bjournal uname=$USERNAME_VALUE uid=$uid assign="last10v4bjournal"]-->
  2.           <td><!--[$last10v4bjournal|pnvarprephtmldisplay]--></td>
Top  MACscr send PM Homepage
 
Chestnut Posted: 12.09.2005, 02:16
Site Admin
avatar

registered: Jun 02, 2002
Posts: 1320

Status:  offline
last visit: 07.02.08
Oupsy... will have to work on that forum template again. icon_smile

mmm you are sending the uid to the plugin but the plugin is checking if the uname is set.

Since it is not... returns false.

Code
  1. if (!isset($uid) || empty($uid)) {
  2.     echo $uid;
  3.     return false;
  4. }


Chestnut ! Cool
Site Admin
Top  Chestnut send PM Homepage
 
MACscr Posted: 12.09.2005, 22:10
Plumber
Plumber


registered: Jan 11, 2005
Posts: 147

Status:  offline
last visit: 19.04.06
Made the change, but for some reason the area is still completely blank. Am i calling it incorrectly in the user_all.tpl file? I think i am, i was just using the last10news reference as an example
Top  MACscr send PM Homepage
 
Chestnut Posted: 12.09.2005, 22:21
Site Admin
avatar

registered: Jun 02, 2002
Posts: 1320

Status:  offline
last visit: 07.02.08
I see very small things, one that could be the answer but the rest... should not stop it.

The biggest issue although it might not be one is your template call

Code
  1. $template = $template."/advProfile_plugin_v4bjournal.tpl";


It might not be an error though but since you used the word last10v4bjournal everywhere else... (missing last10 part.)

As for the rest, 99% ok I think. You have a "; at the end of your link in your template but shouldn't break the plugin.

Chestnut ! Cool
Site Admin
Top  Chestnut send PM Homepage
 
MACscr Posted: 21.09.2005, 08:05
Plumber
Plumber


registered: Jan 11, 2005
Posts: 147

Status:  offline
last visit: 19.04.06
Well, im back to work to see if i can get it to work. No luck with the last changes u mentioned. I still have a feeling im calling it incorrectly in my advprofile template.
Top  MACscr send PM Homepage
 
Chestnut Posted: 21.09.2005, 09:16
Site Admin
avatar

registered: Jun 02, 2002
Posts: 1320

Status:  offline
last visit: 07.02.08
Not 100% sure but the only last issue I see is a "; that shouldn't be there :

Code
  1. ....rnal].jjo_title]--></a>";


and the template call that doesn't have "last10" in it :
Code
  1. $template = $template."/advProfile_plugin_v4bjournal.tpl";


If those are fixed,... not seeing much else.

Could you send me a little zippy of the mod at webmaster PUTTHEIDIOTSIGNHERE pnconcept.com ?



Chestnut ! Cool
Site Admin
Top  Chestnut send PM Homepage
 
MACscr Posted: 22.09.2005, 09:54
Plumber
Plumber


registered: Jan 11, 2005
Posts: 147

Status:  offline
last visit: 19.04.06
had something wrong in the plugin file. Things seem to be working fine now. I am getting some extra html showing for some reason though. Need to look into that.

As soon as i have things cleaned up, I will submit the plugin so that you can add it to your downloads if you like.
Top  MACscr send PM Homepage
 
jenslund Posted: 19.10.2005, 19:50
Pizzaman
Pizzaman
avatar

registered: Oct 15, 2005
Posts: 18

Status:  offline
last visit: 26.10.05
Is this PlugIn going to be posted on this site?

Dont ever try to eat a living cow. They're gonna be pissed!
Top  jenslund send PM
 
jadranko Posted: 26.03.2007, 19:50
Noob
Noob


registered: Jan 23, 2005
Posts: 5

Status:  offline
last visit: 26.03.07
Hello,

I have played with the above code for the past 24 hours to no avail. It seems that code in advProfile_plugin_last10v4bjournal.php

Code
  1. <!--[if $last10v4bjournal]-->


never happens and instead the else part is executed.

Someone please help. Atached is the code for all 3 files in question, with changes suggested by chestnut:


advProfile_plugin_last10v4bjournal.php
Code
  1. <table >
  2.   <thead>
  3.     <tr>
  4.       <th >Posljednjih 10 Blog-Zurnal Tekstova</th>
  5.     </tr>
  6.   </thead>
  7.   <tbody>
  8.     <tr>
  9.       <td >
  10.         <!--[if $last10v4bjournal]-->
  11.           <ul class="linklist">
  12.             <!--[section name="last10v4bjournal" loop=$last10v4bjournal]-->
  13.               <li><a href="index.php?module=v4bJournal&func=journal_view&id=<!--[$last10v4bjournal[last10v4bjournal].jjo_id]-->&mode=detail" alt="<!--[$last10v4bjournal[last10v4bjournal].jjo_id]-->"><!--[$last10v4bjournal[last10v4bjournal].jjo_title]--></a>
  14.               </li>
  15.               <li>test message in else part 1 of the body</li>
  16.             <!--[/section]-->
  17.           </ul>
  18.         <!--[else]-->
  19.            <li>test message in else part 3a of the body</li>
  20.                        
  21.         <!--[/if]-->
  22.       </td>
  23.      </tr>
  24.   </tbody>
  25. </table>



function.last10v4bjournal
Code
  1. <?php
  2. function smarty_function_last10v4bjournal($params, &$smarty)
  3. {
  4.  
  5.  
  6.     if (!pnSecAuthAction(0, 'advProfile::', 'Plugin::last10v4bjournal.php', ACCESS_READ)) {
  7.         return false;
  8.     }
  9.  
  10.     extract($params);
  11.     unset($params);
  12.  
  13.     if (!isset($uid) || empty($uid)) {
  14.         echo $uid;
  15.         return false;
  16.     }
  17.  
  18.  
  19.     if (!isset($template) || empty($template)) {
  20.         $template = pnModGetVar('advProfile', 'template');
  21.  
  22.     }
  23.  
  24.  
  25.     if (!pnModAvailable('v4bJournal')) {
  26.             return false;
  27.             echo "v4bJournal module does not exist";
  28.     }
  29.  
  30.  
  31.     $dbconn  =& pnDBGetConn(true);
  32.     $pntable =& pnDBGetTables();
  33.  
  34.     $sql="SELECT jjo_id, jjo_title, jjo_lu_date from ".pnConfigGetVar('prefix')."_v4b_journal_journal
  35.     WHERE jjo_owner_uid='$uid' AND jjo_permission!=0 ORDER BY jjo_lu_date DESC";
  36.  
  37. //for debugging
  38. echo $sql;
  39. //
  40.  
  41.     $result = $dbconn->SelectLimit($sql, 10, 0);
  42.  
  43.  
  44.  
  45.  
  46.     if ($dbconn->ErrorNo() != 0) {
  47.         echo $dbconn->ErrorMsg();
  48.         return false;
  49.     }
  50.  
  51.     $last10v4bjournal = array();
  52.  
  53.     for(; !$result->EOF; $result->MoveNext()) {
  54.         list($jjo_id, $jjo_title, $jjo_lu_date) = $result->fields;
  55.  
  56.         $last10v4bjournal[] = array('jjo_id'   => $jjo_id,
  57.                               'jjo_title'   => $jjo_title,
  58.                               'jjo_lu_date' => $jjo_lu_date);
  59.     }
  60.  
  61.  
  62.     $result->Close();
  63.  
  64.     $pnRender =& new pnRender('advProfile');
  65.  
  66.     $pnRender->Assign('last10v4bjournal', $last10v4bjournal);
  67.  
  68.     $template = $template."/advProfile_plugin_last10v4bjournal.tpl";
  69.  
  70.  
  71.     if (!$pnRender->template_exists(pnVarPrepForOS($template))) {
  72.         echo "notexists";
  73.         return false;
  74.     }
  75.  
  76.     //doesn't seem to be used
  77.     //@include_once('modules/advProfile/pnlang/'.pnVarPrepForOS(pnUserGetLang()).'/last10v4bjournal.php');
  78.  
  79.     $tpl = $pnRender->Fetch($template, $uid);
  80.  
  81.  
  82.     if (isset($assign)) {
  83.         $smarty->assign($assign, $tpl);
  84.     } else {
  85.  
  86.         return $tpl;
  87.  
  88.     }
  89.  
  90. }
  91.  
  92. ?>




part of the template advProfile_user_activity that implements the plugin
Code
  1. <tr>   
  2.           <!--[last10v4bjournal uname=$USERNAME_VALUE uid=$uid assign="last10v4bjournal"]-->
  3.           <td colspan="2"><!--[$last10v4bjournal|pnvarprephtmldisplay]--></td>
  4.           <!--<td> </td>-->
  5.         </tr>
Top  jadranko send PM
 
Chestnut Posted: 16.04.2007, 11:11
Site Admin
avatar

registered: Jun 02, 2002
Posts: 1320

Status:  offline
last visit: 07.02.08
if the else part is shown, the plugin is sending false.

All checks not working returning:
Code
  1. return false;

are a potential reason why.

Security check
No userid
v4bJournal unavailable
SQL Error
Template unfound.

(Damn... so late on this, this message is almost a month old).

Chestnut ! Cool
Site Admin
Top  Chestnut send PM Homepage
 



Powered by pnForum Version 2.0.1
DarkMindZ