News:

Wondering if this will always be free?  See why free is better.

Main Menu

[1.1] How to add tabs to Core (NDT)?

Started by JayBachatero, December 31, 2005, 04:21:57 PM

Previous topic - Next topic

dunx

I need help with making a button so users can click off the main menu, to the paid subscription.

I have looked over the code and it baffles me completely can anyone help me?

The button URL would be

http://www.sellyourholiday.com/forum/index.php?action=profile;sa=subscriptions

I will make a small custom button but its the code to put it into my website which confuses the hell out of me..


JayBachatero

Did you follow the tutorial step by step?  Just replace action=chat with action=profile;sa=subscriptions
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

dunx

i tried and failed completely, nothing happens.

i made the button the code etc, nothing showed up, the problem is there are sooo many differnt versions of the code i didnt know which ones to use.  im still confused.

could u post an example I could copy?

JayBachatero

This is the wrong tutorial.  You need the button tutorial not tabs.
How to add buttons
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

dunx

The how to make buttons search you gave me almost all of them lead back to here so i tried to modify my calender code but again nothing happens, here is my code:

// The [subscriptions]!
   if ($context['allow_subscriptions'])
      echo ($current_action == 'profile;sa=subscriptions' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'profile;sa=subscriptions' ? 'active_back' : 'back' , '">
               <a href="', $scripturl, '?action=profile;sa=subscriptions">' , $txt['calendar24'] , '</a>
            </td>' , $current_action == 'profile;sa=subscriptions' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

JayBachatero

Do this

Add this on top

if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'subsciptions')
$current_action = 'subscriptions';


Then for the button itself use this.

// The [subscriptions]!
   if ($context['allow_subscriptions'])
      echo ($current_action == 'subscriptions' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'subscriptions' ? 'active_back' : 'back' , '">
               <a href="', $scripturl, '?action=profile;sa=subscriptions">Subscriptions</a>
            </td>' , $current_action == 'subscriptions' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Deaks

Jay how would you go about changing the rest of the files to convert the buttons to tabs?
~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

JayBachatero

In your index.template.php file there is an option that says usetabs.  You can try that out.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Deaks

tried

// Initialize the template... mainly little settings.
function template_init()
{
global $context, $settings, $options, $txt;

/* Use images from default theme when using templates from the default theme?
if this is 'always', images from the default theme will be used.
if this is 'defaults', images from the default theme will only be used with default templates.
if this is 'never' or isn't set at all, images from the default theme will not be used. */
$settings['use_default_images'] = 'never';

/* What document type definition is being used? (for font size and other issues.)
'xhtml' for an XHTML 1.0 document type definition.
'html' for an HTML 4.01 document type definition. */
$settings['doctype'] = 'xhtml';

/* The version this template/theme is for.
This should probably be the version of SMF it was created for. */
$settings['theme_version'] = '1.1 RC2';

/* Set a setting that tells the theme that it can render the tabs. */
$settings['use_tabs'] = true;

/* Use plain buttons - as oppossed to text buttons? */
$settings['use_buttons'] = false;

/* Show sticky and lock status seperate from topic icons? */
$settings['seperate_sticky_lock'] = true;
}


and // Initialize the template... mainly little settings.
function template_init()
{
global $context, $settings, $options, $txt;

/* Use images from default theme when using templates from the default theme?
if this is 'always', images from the default theme will be used.
if this is 'defaults', images from the default theme will only be used with default templates.
if this is 'never' or isn't set at all, images from the default theme will not be used. */
$settings['use_default_images'] = 'never';

/* What document type definition is being used? (for font size and other issues.)
'xhtml' for an XHTML 1.0 document type definition.
'html' for an HTML 4.01 document type definition. */
$settings['doctype'] = 'xhtml';

/* The version this template/theme is for.
This should probably be the version of SMF it was created for. */
$settings['theme_version'] = '1.1 RC2';

/* Set a setting that tells the theme that it can render the tabs. */
$settings['use_tabs'] = true;

/* Show sticky and lock status seperate from topic icons? */
$settings['seperate_sticky_lock'] = true;
}


But still it doesnt show the tabs outside of the index.template
~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

JayBachatero

Take a look and see how it's one in Memberlist.template.php.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

cj morin

okay i got the tab working but how do you make it load inside i am using 1.1rc2 and tp0.8.6(i think).  right now it opens a new page in the same window, but i want it to open in the same page kind of like this http://www.timodonnell.co.uk/index.php?action=coppermine. [nofollow]  i am sorry if this is not the place to post, but i have tried searching here and at coppermine.  i hope i have explained this correctly any help would be appreciated

JayBachatero

Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

nitecrawler

I've followed the tab button procedure. However the problem I face is slightly different from it.

In this case, I do not have a fixed url for which the button should point. It is an 'Add to Del.icio.us' Button.

// The [Add to Del.iciou.us] Button!
echo ($current_action == 'delicious' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'delicious' ? 'active_back' : 'back' , '">
               <a href="[color=red][b]<URL>[/b][/color]">Add to Del.icio.us</a>
            </td>' , $current_action == 'delicious' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


I want the <URL> to be like: http://del.icio.us/post?url=Curent Document Location&title=Current Document Title

I've the javascript code for it.

Quote<script language='javascript'>
document.write("<a href='Del.icio.us</a>")
</script>

But how do i have this url set in the place of the button hyperlink?  ::)

Can anyone help me with the code? I am not sure how to embed this js into php.

nitecrawler

I thought i finally got it after hours of searching, but it isn't working..

// Show the [Add to Del.icio.us] button.
echo ($current_action == 'delicious' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'delicious' ? 'active_back' : 'back' , '">
<a href="http://del.icio.us/post?url=' . {$_REQUEST['url']} . '&title=' . {$_REQUEST['title']}. '">Add to Del.icio.us</a>"
</td>' , $current_action == 'delicious' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


Am i missing something here?  :'(

JayBachatero

Try replacing

<a href="http://del.icio.us/post?url=' . {$_REQUEST['url']} . '&title=' . {$_REQUEST['title']}. '">Add to Del.icio.us</a>"


with

<script language="javascript">
document.write("<a href=\'http://del.icio.us/post?url="+encodeURIComponent(document.location.href)+ "&title="+encodeURIComponent(document.title)+"\'>Add to Del.icio.us</a>")
</script>
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

nitecrawler

Thank you, thank you, thank you! It worked  :D

My presumption that the js embedded like that in PHP made it all wrong... I acknowledge that at times being completely unaware is better than being slightly aware!..  8)

JayBachatero

The JS has ' and you must escape them to echo them.  Escaping them mean change ' to \'
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Penelope

#137
Thanks for all the info!  :D

I have only one question. I made a new menu item "Hall of Fame" and when i go on that page, the "Home" and "Hall of Fame" button are selected, which should only be the "Hall of Fame" button.

Any idea what is wrong? Hope someone can help me!

in the index.template i have this:

//Hall of fame menu button
if ($context['current_action'] == 'halloffame')
$current_action = 'halloffame';
echo ($current_action=='halloffame' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'halloffame' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=halloffame">Hall of Fame</a>
</td>' , $current_action == 'halloffame' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


in the halloffame.php file i have this:

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

function 
halloffame() {
// This is gonna be needed...
loadTemplate('halloffame');
}


in the halloffame.template i have this:

<?php
// Version: 1.1 RC2; Gallery

function template_main()
{
global $context$settings$options$txt$scripturl;

echo '
<script language="JavaScript" type="text/javascript"><!--
function checkAll(onOff)
{
for (var i = 0; i < document.searchform.elements.length; i++)
{
if (document.searchform.elements[i].name.substr(0, 3) == "brd")
document.searchform.elements[i].checked = onOff;
}
}
// --></script>
<form action="'
$scripturl'?action=search2" method="post" name="searchform" id="searchform">

 <script type="text/javascript"><!--

/***********************************************
* IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["myframe"]

//Should script hide iframe from browsers that don\'t support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller

// --></script>

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

/*   
 *   Podium Hall of Fame
 *   
 *   
 */

echo ' <center><table border="0" width="95%" cellspacing="1" cellpadding="5" class="bordercolor">
<tr class="catbg">
<td align="center" colspan = 3>
<img src="">
<a href="'
.$scripturl.'?action=arcade">Hero Members</a><img src="">
</td>
</tr>
<tr align="center">
'
;
if(!empty($data_1[2]["name"])){
echo'
<td class="windowbg" width="33%">
<img src="" border="0" /> <br />
'
.$data_1[2]["avatar"].' <br/>
<a href="'
.$scripturl.'?action=profile;u='.$data_1[2]["id"].'">'.$data_1[2]["name"].'</a> <br/>
(<b>'
.$data_1[2]["count"].'</b> Highscores)
</td>
'
;
}else{
echo'
<td class="windowbg" width="33%">
&nbsp;
</td>



<td class="windowbg" width="33%">
<img src="" border="0" /> <br />

<a href=""></a> <br/>

</td>
<td class="windowbg" width="33%">
&nbsp;
</td>
'
;
}
if(!empty($data_1[3]["name"])){
echo'
<td class="windowbg" width="33%">
<img src="" border="0" /> <br />
'
.$data_1[3]["avatar"].' <br/>
<a href="'
.$scripturl.'?action=profile;u='.$data_1[3]["id"].'">'.$data_1[3]["name"].'</a> <br/>
(<b>'
.$data_1[3]["count"].'</b> Highscores)
</td>
'
;
}else{
echo'

'
;
}
echo'
</tr>
</table></center>
'
;


/*
 * End podium Hall of Fame
 *
 *
 */






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

?>

JayBachatero

This is your problem.
$current_action = 'halloffame';

Refer to step one.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Penelope

Thanks for your fast reply, but can you please be more specific :-[  :D

I am not an experienced php'er  ;)  :-[ :D

Advertisement: