TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online

[Discussion] Tabbed Block by Mouse Over

Started by Freddy, September 05, 2009, 05:31:46 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

alhaudhie

ok.. thanks about ur suggestion.. there is better i ask the mod author.. coz this topic is about MOUSE OVER TABBED not for the chat.

stormlrd

Very nice freddy, I downloaded it and will check it more tomorrow, im running the old one i had in a side block now on my dsu forum. I like the look of it great job

Freddy

Thanks StrormLrd I hope you like what we did with your code - it was a great base to work from.  Hopefully I credited you properly in various places if not let me know.

Cheers :)

stormlrd

Not a problem bro, from what ive seen youve done far more with it :D  I'll look into more today if my net gets better right now its really crappy lol

Rav33n

I'm having a small problem with some odd behaviour in a tabbed block:

I have a recent topics block (normal php block) that shows a new.gif image next to each topic link on the front page, but the exact same code inside a tabbed block does not show the new.gif image next to unread topics. EDIT: no images at all appear in the tabbed version of the block.

this is the code:

global $scripturl;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="titlebg">Recent topics</td></tr> ';
       $what=ssi_recentTopics('25', NULL, 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="20%">
                                                ', $topic['poster']['link'], '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="35%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';


Basically, the behaviour changes when inside a tabbed block (inside mouseovertabcontent.php) even though the code is exactly the same. I've attached my mouseovertabcontent.php.

Would be very grateful if you could take a look freddy :)

Freddy

First, well done for figuring out so much already, you did a nice job with this - I know it's not the easiest thing to work with :)

All you need to do here is add a few things to your globals line like so :

global $scripturl, $settings, $txt, $context;

This makes them available for use within a function - each function will need it's own set of globals depending on what you use.  You may/will find you need to do something similar with your other functions.  The four variables above in that line of code I posted are the main ones usually.

Let me know how you get on, good luck :)


Rav33n

Quote from: freddy888 on March 23, 2010, 12:40:07 PM
Let me know how you get on, good luck :)

Worked. Better support than some paid mods I've tried... ty.

Atomiq25

#87
hi, first of all thanks for the code, it is useful as it is.

but i have a few questions:

1.- how can i show articles of an specific category

like tab 8, but no only one, i want to show a bunch of them separated

vertically and sorted from recent to older

----

2.- how can i add this code:

Quoteglobal $sourcedir, $settings;

// show_form = 0 ---> only message without form
// show_form = 1 ---> message + form
// show_form = 2 ---> only form without message
$show_form = 1;
$num_items = 5;
$only_profile = false; // true show only your items, false show all items

if (!allowedTo('smfsocialnetwork_access'))
   echo 'Sorry, you cannot access to SMF Social Network';
elseif (!file_exists($sourcedir . '/SMFSocialNetwork.php'))
   echo 'No SMFSocialNetwork.php file found';
elseif (!file_exists($sourcedir . '/SMFSocialNetwork-Subs.php'))
   echo 'No SMFSocialNetwork-Subs.php file found';
elseif (!file_exists($settings['default_theme_dir'] . '/SMFSocialNetwork.template.php'))
   echo 'No SMFSocialNetwork.template.php file found';
else
{
   require_once($sourcedir . '/SMFSocialNetwork.php');
   smfsocialnetwork_portal_block($num_items, $show_form, $only_profile);
}

already tried but i failed:

Quotefunction mot_Search()

{

   global $sourcedir, $settings;

   echo '

<div class="tabsmenucontent" style="padding: 5px">'


$show_form = 1;
$num_items = 5;
$only_profile = false; // true show only your items, false show all items

if (!allowedTo('smfsocialnetwork_access'))
   echo 'Sorry, you cannot access to SMF Social Network';
elseif (!file_exists($sourcedir . '/SMFSocialNetwork.php'))
   echo 'No SMFSocialNetwork.php file found';
elseif (!file_exists($sourcedir . '/SMFSocialNetwork-Subs.php'))
   echo 'No SMFSocialNetwork-Subs.php file found';
elseif (!file_exists($settings['default_theme_dir'] . '/SMFSocialNetwork.template.php'))
   echo 'No SMFSocialNetwork.template.php file found';
else
{
   require_once($sourcedir . '/SMFSocialNetwork.php');
   smfsocialnetwork_portal_block($num_items, $show_form, $only_profile);
}


   echo '

</div>';

}

i know, i'm not PHP pro.. xD, i just put the code where it says "  // All your code goes here..."

and replaced the global..

is not a new entry, i'm replacing search tab because i dont need it

hope to get some help ASAP, thanks =)

this is the MOD

tp 1.0 b4, smf 1.1.11 here

Freddy

#88
For question one you want to be doing something like this :

This is the new function to go in the mouseoverTabContents.php :

// $category is an array of the categories to pick from.
// $limit is to limit the number of articles shown.
function mot_TPArticlesByCat($category, $limit)
{
global $settings, $db_prefix;

$tp_prefix = $settings['tp_prefix'];

$result = db_query("SELECT body
FROM {$tp_prefix}articles
WHERE category IN (" . implode(',',$category) . ")
ORDER BY date DESC
LIMIT $limit",__FILE__, __LINE__);

echo '
<div class="tabsmenucontent" style="padding: 12px">';

while ($row = mysql_fetch_assoc($result))
{
echo '
<div style="margin-bottom: 10px">
' , html_entity_decode($row['body']) , '
</div>';
}

echo '
</div>';

mysql_free_result($result);
}


You would call that like so in the configuration area :

// Tab 10 or whatever - categories as array, limit number of articles
// eg - categories 4 and 5 with a limit of 6.
mot_TPArticlesByCat(array(4,5),6);



I am not familiar with that mod, I will take a look at it.... a link to wherever it is would be useful... the code itself is not really enough information.

Freddy

#89
Nevermind I managed to find it.  This is the code I used to make it work, firstly the new function :

function mot_SocialNetwork()
{
global $sourcedir, $settings;

echo '
<div class="tabsmenucontent" style="padding: 5px"';

// show_form = 0 ---> only message without form
// show_form = 1 ---> message + form
// show_form = 2 ---> only form without message
$show_form = 1;
$num_items = 5;
$only_profile = false; // true show only your items, false show all items

if (!allowedTo('smfsocialnetwork_access'))
echo 'Sorry, you cannot access to SMF Social Network';
elseif (!file_exists($sourcedir . '/SMFSocialNetwork.php'))
echo 'No SMFSocialNetwork.php file found';
elseif (!file_exists($sourcedir . '/SMFSocialNetwork-Subs.php'))
echo 'No SMFSocialNetwork-Subs.php file found';
elseif (!file_exists($settings['default_theme_dir'] . '/SMFSocialNetwork.template.php'))
echo 'No SMFSocialNetwork.template.php file found';
else
{
require_once($sourcedir . '/SMFSocialNetwork.php');
smfsocialnetwork_portal_block($num_items, $show_form, $only_profile);
}

echo '
</div>';

}


And then in the config area I used :

// Tab 6
mot_SocialNetwork();


Works fine, see image below....

Don't forget about setting up your buttons right.

Hope that helps :)

This website is proudly hosted on Crocweb Cloud Website Hosting.