User Panel

Welcome, Guest.
Please login or register.

 
 
 

Did you miss your activation email?

 Who's Online

  • • Users: 3
  • • Guests: 23

 Shoutbox

 Theme Changer

 Recent Posts

Sephiroth & Mewtwo
Last Poster: Dismal Shadow | Today at 04:01:12 AM

Re: Download DP?
Last Poster: live627 | Yesterday at 05:25:11 PM

Re: Team Page Mod
Last Poster: ccbtimewiz | September 08, 2010, 02:36:06 AM

Re: Google Mail
Last Poster: ccbtimewiz | September 07, 2010, 01:12:24 AM

Re: Meet the Team - ccbtimewiz
Last Poster: Matt | September 06, 2010, 06:21:48 AM

Re: Dream Portal signature
Last Poster: hadesflames | September 05, 2010, 01:51:59 AM

Re: [WIP] Simple Listings
Last Poster: hadesflames | September 04, 2010, 07:45:09 PM

Re: Hey
Last Poster: ѕησω | September 04, 2010, 10:08:55 AM

Re: Dream Portal in your Language
Last Poster: smithtrd | September 03, 2010, 08:45:16 PM

Author Topic: Latest post/ Active Topics  (Read 355 times)

0 Members and 1 Guest are viewing this topic.

Offline Deezel

  • Quality Assurance
  • *
  • Posts: 46
  • Gender: Male
  • Wannabe Graphics Dude
Latest post/ Active Topics
« on: June 14, 2010, 02:19:38 PM »
I'd like to create this mod, I have the PHP code but does not seem to work in a "Custom Module" if anyone would like to help me take this on I would greatly appreciate it. I have no clue where to begin.
Deezel





Offline SoLoGHoST

  • Dreamer
  • ******
  • Posts: 1,239
  • Gender: Male
  • // Real programmers don't comment their code! :)
Re: Latest post/ Active Topics
« Reply #1 on: June 14, 2010, 02:58:30 PM »
huh?  You can do this already with the Recent Module.  Switch it to Posts and/or topics.  If you want both, make a clone of it, and than have 1 set to topics and the other set to posts.  Not sure what you are talking about.

Offline Deezel

  • Quality Assurance
  • *
  • Posts: 46
  • Gender: Male
  • Wannabe Graphics Dude
Re: Latest post/ Active Topics
« Reply #2 on: June 14, 2010, 03:10:12 PM »
Check here to see what it looks like.
http://thehangout.deezelshouse.com/index.php
Deezel





Offline SoLoGHoST

  • Dreamer
  • ******
  • Posts: 1,239
  • Gender: Male
  • // Real programmers don't comment their code! :)
Re: Latest post/ Active Topics
« Reply #3 on: June 14, 2010, 03:18:27 PM »
Ok, I see what you mean, so you want both of these within the same block.  Not that difficult to do.

You wanna post up the code?  And I should be able to come up with something for you to start off with than, k?

But I have to be at work today by 4pm, so if you don't post it up within the next 15 minutes than I'll have to have a look later on tonight.

Cheers :)
« Last Edit: June 14, 2010, 03:21:07 PM by SoLoGHoST »

Offline Deezel

  • Quality Assurance
  • *
  • Posts: 46
  • Gender: Male
  • Wannabe Graphics Dude
Re: Latest post/ Active Topics
« Reply #4 on: June 14, 2010, 03:22:37 PM »
Code is below, I would like to make sure credit for the code goes to Shortie from Graphics Mayhem.

Code: [Select]
   global $context, $scripturl, $txt, $settings, $color_profile;
echo '
<table cellpadding="5" cellspacing="15" width="100%";>
<tr width="100%";>
<td class="tborder windowbg2" width="50%"; style="text-align: center;">Latest Posts
</td>
<td class="tborder windowbg2" width="50%"; style="text-align: center;">Active Topics
</td>
</tr>

<tr width="100%";>
<td class="tborder windowbg" width="50%";>';
   $block_parameters = array(
      'limit' => 'int',
   );

   if ($return_parameters)
      return $block_parameters;

   $limit = empty($parameters['limit']) ? 7 : (int) $parameters['limit'];
 
    $posts = ssi_recentPosts($limit, null, null, 'array');

   if (empty($posts))
   {
      echo '
                        ', $txt['error_sp_no_posts_found'];
      return;
   }

   $colorids = array();
   foreach ($posts as $post)
      $colorids[] = $post['poster']['id'];

   if (!empty($colorids) && sp_loadColors($colorids) !== false)
   {
      foreach ($posts as $k => $p)
      {
         if (!empty($color_profile[$p['poster']['id']]['link']))
            $posts[$k]['poster']['link'] = $color_profile[$p['poster']['id']]['link'];
      }
   }

   echo '
                        <table class="sp_fullwidth">';

   foreach ($posts as $post)
      echo '
                           <tr>
                              <td class="sp_recent_icon sp_center">
                                 ', sp_embed_image('post'), '   
                              </td>
                              <td class="sp_recent_subject">
                                 <a href="', $post['href'], '">', $post['subject'], '</a>
                                 ', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt['new'] . '" border="0" /></a>', '<br />[', $post['board']['link'], ']
                              </td>
                              <td class="sp_recent_info sp_right">
                                 ', $post['poster']['link'], '<br />', $post['time'], '
                              </td>
                           </tr>';

   echo '
                        </table>';

echo'
</td>
<td  class="tborder windowbg" width="50%";>';
   $block_parameters = array(
      'limit' => 'int',
   );

   if ($return_parameters)
      return $block_parameters;

   $limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 7;

   $topics = ssi_recentTopics($limit, null, null, 'array');

   if (empty($topics))
   {
      echo '
                        ', $txt['error_sp_no_topics_found'];
      return;
   }

   $colorids = array();
   foreach ($topics as $topic)
      $colorids[] = $topic['poster']['id'];

   if (!empty($colorids) && sp_loadColors($colorids) !== false)
   {
      foreach ($topics as $k => $p)
      {
         if (!empty($color_profile[$p['poster']['id']]['link']))
            $topics[$k]['poster']['link'] = $color_profile[$p['poster']['id']]['link'];
      }
   }

   echo '
                        <table class="sp_fullwidth">';

   foreach ($topics as $topic)
      echo '
                           <tr>
                              <td class="sp_recent_icon sp_center">
                                 ', sp_embed_image('topic'), '   
                              </td>
                              <td class="sp_recent_subject">
                                 <a href="', $topic['href'], '">', $topic['subject'], '</a>
                                 ', $topic['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $topic['topic'] . '.msg' . $topic['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt['new'] . '" border="0" /></a>', '<br />[', $topic['board']['link'], ']
                              </td>
                              <td class="sp_recent_info sp_right">
                                 ', $topic['poster']['link'], '<br />', $topic['time'], '
                              </td>
                           </tr>';

   echo '
                        </table>';
echo'
</td>
</tr>
</table>';
Deezel





Offline SoLoGHoST

  • Dreamer
  • ******
  • Posts: 1,239
  • Gender: Male
  • // Real programmers don't comment their code! :)
Re: Latest post/ Active Topics
« Reply #5 on: June 14, 2010, 03:23:48 PM »
Ok, sure thing.

Offline SoLoGHoST

  • Dreamer
  • ******
  • Posts: 1,239
  • Gender: Male
  • // Real programmers don't comment their code! :)
Re: Latest post/ Active Topics
« Reply #6 on: June 14, 2010, 03:42:37 PM »
Here's your module, but there is a problem with this...

Quote
Fatal error: Function name must be a string in /home/graphic3/public_html/subdomains/acs/testdp/Themes/default/DreamPortal.template.php on line 152

Nothing wrong with the module, but most likely another bug that live627 created.  Sorry live627, but you really need to be more careful when making changes to things throughout DP because everything is there for a reason and you need to understand those reasons before you go making any changes.

So here is the module that should work, but doesn't... this is most likely the same problem with the Custom PHP Coding also... not sure.

I'm off to work, so I can't look into why this error is happening unfortunately, because, just now noticing that this same error comes up for the TestModule.zip file that I attached, when viewing the actual page of where that module is.

I apologize, but this worked in all of my revisions, live627, created the RC1 Revision and made quite a few changes... sorry, but hopefully this can be reported in the Bug Tracker and fixed very soon.  Because what good is creating modules, if they don't work?! :(

Offline Deezel

  • Quality Assurance
  • *
  • Posts: 46
  • Gender: Male
  • Wannabe Graphics Dude
Re: Latest post/ Active Topics
« Reply #7 on: June 14, 2010, 03:45:05 PM »
Cheers and thank you sir. 8)
Deezel





Offline Deezel

  • Quality Assurance
  • *
  • Posts: 46
  • Gender: Male
  • Wannabe Graphics Dude
Re: Latest post/ Active Topics
« Reply #8 on: June 14, 2010, 03:54:23 PM »
So basically I just had to put the code between

" <?php
function module_recent2()
{ "

&

" }

?> "

Minus the quotes

Deezel





Offline SoLoGHoST

  • Dreamer
  • ******
  • Posts: 1,239
  • Gender: Male
  • // Real programmers don't comment their code! :)
Re: Latest post/ Active Topics
« Reply #9 on: June 15, 2010, 12:34:20 AM »
You can give it any function name you want.  I choose to use module_recent2 because module_recent is already a used function for the Default Recent Module that comes with Dream Portal.  You can name your module anything and/or the function, but it's good practice to name your functions with the name of your module in it, so that it's not already taken because module names are unique.  So in this case, your module is named recent2, if you take a look at the info.xml, you will see that between the <name> tags is recent2, this is your module's name.  This is important, since all $txt and $helptxt keys must have this name in there.  And it's better practice to use your module's name for function names within the script that handles your module because, if that function already exists, your module will not be able to be added to the installed modules list, since it checks all functions throughout SMF, for MODs installed, as well as Dream Portal Modules, and even Modules that have been added already.  Because you can not have duplicate PHP function names.

But I didn't just put the code in script.php, in fact, your script file doesn't have to be called script.php at all.  But that is easier for us to follow.

Look at it this way, k?  If you've ever created a mod for SMF, this will be easy to understand.  info.xml, is the only file that MUST be named just that, and MUST BE within the ROOT of the .zip package!!  All other files are defined within the info.xml file.  So info.xml has the same exact purpose as package-info.xml that comes packaged up with all SMF Mods.

Well, hopefully you understand what I'm saying.

Cheers :)

Offline Deezel

  • Quality Assurance
  • *
  • Posts: 46
  • Gender: Male
  • Wannabe Graphics Dude
Re: Latest post/ Active Topics
« Reply #10 on: July 28, 2010, 01:29:19 PM »
Aaaaargh................Sorry but I can not figure this stuff out....
If anyone can fix this and make it work as it does on my site ( thehangout.deezelshouse.com) please feel free.
Deezel