Second actions in SMF.

Started by dtm.exe, March 03, 2006, 10:48:15 AM

Previous topic - Next topic

dtm.exe

Normally, I would look to php.net for help with PHP related issues, but I'm not even sure what the technical name is for ?action=action;sa=secondaction.  What would the code be for this and where would the source code for the page be inputted?

kegobeer

Dan, what are you trying to do?
"The truth of the matter is that you always know the right thing to do. The hard part is doing it." - Norman Schwarzkopf
Posting and you (Click "WATCH THIS MOVIE")

dtm.exe

Quote from: kegobeer on March 03, 2006, 11:41:38 AM
Dan, what are you trying to do?

Add a second action to a custom action :).

(ex. ?action=chat;sa=help)

Thantos

the second action would be in the file where the primary action is done.  So the file that handles ?action=chat would then have to handle the secondary action part.

dtm.exe

Quote from: Thantos on March 03, 2006, 05:29:04 PM
the second action would be in the file where the primary action is done.  So the file that handles ?action=chat would then have to handle the secondary action part.

I knew that, I just wanted the code that defines that.  I learned that $_GET can accomplish that.  Thanks for your time, guys :).

1MileCrash

if (@$_REQUEST['action'] == 'action')
{
echo 'this is an action';

if (@$_REQUEST['sa'] == 'subaction')
{
echo' this is a subaction';
}

}


like that.
The only thing php can't do is tell you how much milk is left in the fridge.



dtm.exe

I'm using the following code:
// Second action: help - ?action=chat;sa=help
        if (isset($_GET['sa']) && $_GET['sa'] == 'help')
return ChatHelp();

function ChatHelp() {
          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" >PJIRC Integrated Chat Mod Help</td>
          </tr><tr>
          <td class="windowbg">';

          echo '<table border="0" cellpadding="0" cellspacing="3" width="100%">
          <tr>
           <td width="100%" valign="top">
 
  Help.

   </td></tr></table>';
        echo '
        </td>
        </tr>
        </table><br /><br />';
}


But it's returning the normal chat page with the help box OVER the entire page.  Any idea as to why?

http://pjirc.dtmdotexe.com/index.php?option=com_smf&Itemid=26&action=chat
http://pjirc.dtmdotexe.com/index.php?option=com_smf&Itemid=26&action=chat;sa=help

1MileCrash

#7
i dont know exactly how you made the chat action in the first place. ill just redo it in my example.

where do you want it? if you just want it to take the place of the chat applet, or above it, just do:

if (@$_REQUEST['action'] == 'chat')
{

if (@$_REQUEST['sa'] == 'help')
{
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" >PJIRC Integrated Chat Mod Help</td>
          </tr><tr>
          <td class="windowbg">';

          echo '<table border="0" cellpadding="0" cellspacing="3" width="100%">
          <tr>
           <td width="100%" valign="top">
 
  Help.

   </td></tr></table>';
        echo '
        </td>
        </tr>
        </table><br /><br />';
}
else
{
echo' <p/><p/>pretend this is the chat ';
}
}
?>


^to take the place of the chat - http://www.model98.org/subaction2.php?


if (@$_REQUEST['action'] == 'chat')
{

if (@$_REQUEST['sa'] == 'help')
{
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" >PJIRC Integrated Chat Mod Help</td>
          </tr><tr>
          <td class="windowbg">';

          echo '<table border="0" cellpadding="0" cellspacing="3" width="100%">
          <tr>
           <td width="100%" valign="top">
 
  Help.

   </td></tr></table>';
        echo '
        </td>
        </tr>
        </table><br /><br />';
}

echo' <p/><p/>pretend this is the chat ';
}
?>



^ to just be above the chat - http://www.model98.org/subactions.php?
The only thing php can't do is tell you how much milk is left in the fridge.



dtm.exe

Tipp, the SA is settled and setup properly.  The problem is that the page is loading ABOVE the main chat page.  One would assume that it would do the exact same for your script.

1MileCrash

it's not though. i use it all the time on my pages..
The only thing php can't do is tell you how much milk is left in the fridge.



dtm.exe

Quote from: Tippmaster on March 04, 2006, 12:59:45 AM
it's not though. i use it all the time on my pages..

Just to prove a point, I tried it on my forum.  After copying and pasting your code (and adding an extra } at the end that was left out), the same exact thing happens.

1MileCrash

show me where i need the } at...i may have made that mistake on real stuff.

why does it work on my examples/site though?
http://www.model98.org/subactions.php?action=chat;sa=help
http://www.model98.org/subactions.php?action=chat
The only thing php can't do is tell you how much milk is left in the fridge.



dtm.exe

Quote from: Tippmaster on March 04, 2006, 01:19:34 AM
show me where i need the } at...i may have made that mistake on real stuff.

why does it work on my examples/site though?
http://www.model98.org/subactions.php?action=chat;sa=help
http://www.model98.org/subactions.php?action=chat

I didn't scroll down enough to copy the last }, therefore I missed it.  My bad.

Why does it work on your website and not mine, you ask?  I don't know; you tell me.

sadiqbaig

#13
i have added this code in links.php



<?php

if (!defined('SMF'))
die(
'Hacking attempt...');
function 
Links() {
global $context;
$context['page_title'] = 'LinkXchange!';
// This is gonna be needed...
loadTemplate('Links');

if (isset(
$_REQUEST['action']) && $_REQUEST['action'] == 'links')
{
      
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" >LinkXchange</td>
</tr><tr>
<td class="windowbg">'
;

echo 
'Computer <a href="?action=links&amp;subaction=Computer">Computer</a><br />';
echo 
'Games <a href="?action=links&amp;subaction=Games">Games</a><br />';
 
}
    
//This handles the subactions.
    
if (isset($_REQUEST['subaction']) && $_REQUEST['subaction'] == 'Computer')
    {
    
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" >Computer</td>
</tr><tr>
<td class="windowbg">'
;

 echo 
'<a href="http://www.thewapforum.com/wapxlinkxx/affout.php?aff=T13" target="_blank">AdWords</a>&nbsp;&nbsp;';
}

    if (isset(
$_REQUEST['subaction']) && $_REQUEST['subaction'] == 'Games')
    {
            
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" >Games</td>
</tr><tr>
<td class="windowbg">'
;

 echo 
'<a href="http://www.thewapforum.com/wapxlinkxx/affout.php?aff=T13" target="_blank">AdWords</a>&nbsp;&nbsp;';
}

    }



?>



but when i click this

http://thewapforum.com/wapforum/index.php?action=links&subaction=Computer

the link is displayed in template menu

not in links template



Advertisement: