TinyPortal

Development => Support => Topic started by: 0uK^- on January 01, 2007, 11:01:47 PM

Title: Custom Actions and Tp Blocks
Post by: 0uK^- on January 01, 2007, 11:01:47 PM
Hi there.

I have one problem.  :-\

I create one new custom action but i need in that action show the blocks from tp.

I search and find this topic:
http://www.tinyportal.net/index.php?topic=5495.0

But don't show the blocks  :'(

I put for example in the Sources/Test.php
<?php

if (!defined('SMF'))
die('Hacking attempt...');

function
Test()
{
global $context;

//Check if the current user can send a message
   
$context['page_title'] = 'Just Testing;
  $context['
linktree'][] = array(
'
url' => $scripturl . '?action=Test',
'
name' => 'Test'
);
   $context['
TPortal']['leftbar']=1;
loadTemplate('
Test');
}
?>


But don't show any blocks =(

Can someone help me?

Sorry for my English
Title: Re: Custom Actions and Tp Blocks
Post by: IchBin on January 02, 2007, 03:14:20 AM
Your custom actions need to be set to display in the index.template file. If not, you'll have to manually add the code for the sidepanels.
Title: Re: Custom Actions and Tp Blocks
Post by: brianjw on January 02, 2007, 03:24:33 AM
Info
1. Display.test.php - needs to have what you want to appear
2. Test.php - I am not sure. But I could give you better instructions when I get time
--------There is a few more you must do but I will make better directions in a few days---------
Title: Re: Custom Actions and Tp Blocks
Post by: 0uK^- on January 02, 2007, 10:25:06 AM
Quote from: IchBinâ„¢ on January 02, 2007, 03:14:20 AM
Your custom actions need to be set to display in the index.template file. If not, you'll have to manually add the code for the sidepanels.
Sorry i didn't understand  :-\

I have in Test.php
<?php

if (!defined('SMF')) die('Hacking attempt...');

function
Test()
{
global $context;

//Check if the current user can send a message
   
$context['page_title'] = 'Just Testing;
  $context['
linktree'][] = array(
'
url' => $scripturl . '?action=Test',
'
name' => 'Test'
);
   $context['
TPortal']['leftbar']=1;
loadTemplate('
Test');
}
?>

And in the Test.template.php
function template_main()
{
global $context, $settings, $options, $txt, $scripturl;

echo '


<table width="100%" border="0" cellspacing="0" cellpadding="3" >
<tr>
<td>', theme_linktree(), '</td>
</tr>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="4" align="center" class="tborder">
<tr class="titlebg">
<td align="center" >Testing</td>
</tr><tr>
<td class="windowbg">';

echo '<table border="0" cellpadding="0" cellspacing="3" width="100%">
         <tr>
           <td width="100%" valign="top">
  Just Testing
</td></tr></table>';
echo '
</td>
</tr>
</table><br /><br />
';
}


And the result is this:
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg208.imageshack.us%2Fimg208%2F8874%2Fnoblocksrf9.th.png&hash=f2900dde8ae43e7a17fff6b08ad4a9d018e1fdee) (http://img208.imageshack.us/my.php?image=noblocksrf9.png)

But when i unhide the blocks in the Forum the blocks appears.

I want the blocks hide in forum and in the action Test unhide.
Title: Re: Custom Actions and Tp Blocks
Post by: G6Cad on January 02, 2007, 10:39:00 AM
Quote from: brianjw on January 02, 2007, 03:24:33 AM
Info
1. Display.test.php - needs to have what you want to appear
2. Test.php - I am not sure. But I could give you better instructions when I get time
--------There is a few more you must do but I will make better directions in a few days---------

Brian, we appriciate you helping where you can, but please.
If you dont have the TIME to end the help or write it so they understand, keep from posting at all, the threads just get to long with out any good content and thats the same as having a usless topic about nothing in the end.
So when you help, take the time and go through with the help you want to give, or please dont post at all in it ;)
Title: Re: Custom Actions and Tp Blocks
Post by: brianjw on January 02, 2007, 01:26:04 PM
Some instructions to doing your test action.-

Backup any files i tell you to edit before trying this.


Open the index.php

Search For

'sticky' => array('LockTopic.php', 'Sticky'),

Add after

'test' => array('test.php', 'test'),

Open up the Modifications.english.php file in your languages directory.

Add this after another text string on the page.


$txt['test'] = 'Test';

Then create the test.php Page

<?php


if (!defined('SMF'))
die('Hacking attempt...');

function
test()
{
global $context, $mbname, $txt;


//Load the main test template
loadtemplate('test');

//Load the main test template
$context['sub_template']  = 'main';
//Set the page title
$context['page_title'] = $mbname . ' - ' . $txt['Test'];

}
?>



Next Create the test.template.php page.

<?php
/*
Test Page
*/
function template_main()
{
global $db_prefix, $scripturl, $txt, $user_info,$settings, $modSettings;

echo
'
<b>Add the code of the object you want displayed in between the echo tag</b>
'
;
 
}
?>


Where you see Add the code of the object you want displayed in between the echo tag you add the code of the object that will be displayed in that action.


test.php Goes in the sources directory , test.template.php goes in the default themes directory.


Caps or small letters does matter!! if i dont use a capital letter you shouldnt either!!

Hope this is useful to someone.

Those were the instructions and you must follow all those directions to add a action correctly. It looked to me like you only did test.php and test.template.php so you must follow the other files as well.

Thanks,
Brianjw
Title: Re: Custom Actions and Tp Blocks
Post by: 0uK^- on January 02, 2007, 03:31:32 PM
brianjw, thanks but its not my question.

My question is how can i add the TpBlocks in the custom action.  :-\
Title: Re: Custom Actions and Tp Blocks
Post by: IchBin on January 02, 2007, 03:43:42 PM
brianjw gave you the answer pretty much. If you add your custom action as he pointed out, your test.template.php will load inside the index.template.php file. By default the index.template.php file shows the sidebars.
Title: Re: Custom Actions and Tp Blocks
Post by: bloc on January 02, 2007, 04:00:18 PM
Since any custom action is assumed to be the "forum" part, the setting for hiding panels when in forum, will set in whenever your custom action is run.

I rather suggest you set them on in the forum to be able to see them. Or - use the extended visiblity options for each block and make that block show when in your custom action. Choose "custom" and type in the action name in the filed next to it. it should then display in your custom action even if blocks are set to be hidden in forum.
Title: Re: Custom Actions and Tp Blocks
Post by: 0uK^- on January 02, 2007, 04:14:34 PM
Thanks  :)

I did it....

Tkz for the help.  :up:
Title: Re: Custom Actions and Tp Blocks
Post by: brianjw on January 02, 2007, 04:34:16 PM
No Problem :)
Title: Re: Custom Actions and Tp Blocks
Post by: Tommy on March 22, 2007, 05:27:48 PM
Quote from: Bloc on January 02, 2007, 04:00:18 PM
Since any custom action is assumed to be the "forum" part, the setting for hiding panels when in forum, will set in whenever your custom action is run.

I rather suggest you set them on in the forum to be able to see them. Or - use the extended visiblity options for each block and make that block show when in your custom action. Choose "custom" and type in the action name in the filed next to it. it should then display in your custom action even if blocks are set to be hidden in forum.

Well...is there no option to display the right panel on the custom action page even if it's deactivated in the forum? I only want to display the right panel on the forums index - and on my custom action (action=hpnews).

Yep, i could use the "extended visibility option" but for that I need two (but the same) blocks.
One for the index and one for my custom action page...
Title: Re: Custom Actions and Tp Blocks
Post by: Thurnok on March 23, 2007, 03:45:37 AM
hehe... this is the first time I came across this topic, but I'm assuming that OuK^- fixed the error in the code that is in his first post since he later posts he got it... LOL

FYI, if you are wondering...

<?php
.
.

$context['page_title'] = 'Just Testing;

.
.
?>



should be:

<?php
.
.

$context['page_title'] = 'Just Testing';

.
.
?>

Title: Re: Custom Actions and Tp Blocks
Post by: bloc on March 23, 2007, 01:29:59 PM
Quote from: Dubidu on March 22, 2007, 05:27:48 PM
Quote from: Bloc on January 02, 2007, 04:00:18 PM
Since any custom action is assumed to be the "forum" part, the setting for hiding panels when in forum, will set in whenever your custom action is run.

I rather suggest you set them on in the forum to be able to see them. Or - use the extended visiblity options for each block and make that block show when in your custom action. Choose "custom" and type in the action name in the filed next to it. it should then display in your custom action even if blocks are set to be hidden in forum.

Well...is there no option to display the right panel on the custom action page even if it's deactivated in the forum? I only want to display the right panel on the forums index - and on my custom action (action=hpnews).

Yep, i could use the "extended visibility option" but for that I need two (but the same) blocks.
One for the index and one for my custom action page...
No, not currently..because the blocks are fetched quite early and aslo consider the "hide in forum" setting, its hard to do this.

In TP 0.9.5 and earlier it WAS possible - because the hide-in-forum setting was applied  after the blocks were loaded. But since the introduction of dynamic blocks, I had to add that setting into the fetching routine itself. Its more resource friendly this way, only loading what you need. 
Title: Re: Custom Actions and Tp Blocks
Post by: sc2forums on June 10, 2007, 07:34:18 AM
Quote from: Bloc on January 02, 2007, 04:00:18 PM
Since any custom action is assumed to be the "forum" part, the setting for hiding panels when in forum, will set in whenever your custom action is run.

I rather suggest you set them on in the forum to be able to see them. Or - use the extended visiblity options for each block and make that block show when in your custom action. Choose "custom" and type in the action name in the filed next to it. it should then display in your custom action even if blocks are set to be hidden in forum.

I've been trying to do the same thing, but I don't have the option "custom" in the dropdown menu... there is the field for entering the custom name next to it, but no 'custom"? Any help would be appreciated! Thanks!
Title: Re: Custom Actions and Tp Blocks
Post by: IchBin on June 11, 2007, 01:05:24 AM
Thats all you need. You put the name of the custom action in the text box.
Title: Re: Custom Actions and Tp Blocks
Post by: Tommy on July 07, 2007, 03:09:10 PM
Hi,

does anyone know a "theme code" for a custom action site, so I can choose a theme for it - like in smf boards "Board Theme
This allows you to change the look of your forum inside only this board." ?
Would be great - thanks!

/Edit: oops, you guys don't give support for smf questions, right? Then forget it...  :(