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

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

Previous topic - Next topic

nipun_jain


Ravyn

#181
Hello,

Edit* Found the answer to my problem after some more searching, thanks anyways to anyone that read this.

I read through the whole thread, but never saw this question asked, and through playing with different options, I can't seem to get it to work.

I changed the link for my Home tab by replacing the ', script_url ,' dealy, and want to do the same with my logout link.

if ($context['user']['is_logged'])
echo ($current_action == 'logout' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'logout' ? 'active_back' : 'back' , '">
<a href="http://www.mysite.com/index.php?action=logout;sesc=', $context['session_id'], '">' , $txt[108] , '</a>
</td>' , $current_action == 'logout' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


Is my last attempt.. the original code being:

// Otherwise, they might want to [logout]...
if ($context['user']['is_logged'])
echo ($current_action == 'logout' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'logout' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">' , $txt[108] , '</a>
</td>' , $current_action == 'logout' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


I've tried a few other attempts at making it work, and I've gotten just the link to work properly, but the logout action doesn't take place.  Any help would be appreciated, thanks.
Ravyn
-SMF Newbie in Training

Alt-Ctrl

#182
Hi, I'm trying to get a button in my forum that directs the user back to the portal.

I've tried to follow this tutorial, but I'm getting an error on the last line. I don't understand what it is.
And shouldn't it be a place where I can put in the adress to where I want the button to point?


Yeah, I'm a noob

//Show the [main] button.
echo ($current_action=='main' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'main' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '">' '?action=main">Main</a>
</td>' , $current_action == 'main' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

Ravyn

#183
Hey Alt-Ctrl,

I'm by no means an expert on SMF, but from reading through this tutorial I think I can help you out (Experts, please corrent me if I'm wrong :) )

Your error is coming from an improper <a href> call for the action.  Your code should read as follows:

//Show the [main] button.
echo ($current_action=='main' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'main' ? 'active_back' : 'back' , '">
<a href="http://www.mysite.com?action=main">Main</a>
</td>' , $current_action == 'main' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


And in answer to your second question, to tell the button which URL to link to, just place it into the <a href= tag, in place of $scripturl, as shown above.


Hope that helps, if it doesn't work, I'm sure someone more versed with SMF will be along soon to help you out.

Edit*  For your needs, I believe you just want a button that will take the user back to the main url.  If that's the case, this code should suffice for your needs:
//Show the [main] button.
echo ($current_action=='main' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'main' ? 'active_back' : 'back' , '">
<a href="http://www.mysite.com">Main</a>
</td>' , $current_action == 'main' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';



Replace http://www.mysite.com with wherever you want it to link to of course.
Ravyn
-SMF Newbie in Training

Ravyn

Well, after helping someone else with adding a button, I've come across an error myself when adding a button (Oh, the irony).  Anyways, I've added the button.  It only shows up when people are logged in, which is how I want it. The button goes to the proper url.. infact everything with the button works fine.. the only problem is I get the following error code at the top of my page that the button is on.

Notice: Use of undefined constant forums - assumed 'forums' in /www/html/forums/Sources/Load.php(1702) : eval()'d code on line 95

Notice: Use of undefined constant gallery - assumed 'gallery' in /www/html/forums/Sources/Load.php(1702) : eval()'d code on line 96


I went to find those 2 lines, and this is what they are:

bool sessionOpen(string session_save_path, string session_name)
bool sessionClose()


I added the buttons just as its described in the tutorial:


  // Show the [forums] button.
  if ($context['user']['is_logged'])
    echo ($current_action == 'forums' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'forums' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '">' , $txt[forums] , '</a>
</td>' , $current_action == 'forums' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


and


  if ($context['current_action'] == 'forums')
    $current_action = 'forums';



Any help would be appreciated, thanks.
Ravyn
Ravyn
-SMF Newbie in Training

codenaught

Change ' , $txt[forums] , ' to ' , $txt['forums'] , ' You will need to do the same for the gallery one ' , $txt[gallery] , ' to ' , $txt['gallery'] , '
Dev Consultant
Former SMF Doc Coordinator

Alt-Ctrl

Thanks allot, that worked like a dream  :)

Ravyn

Glad I could be of help Alt-Ctrl, and thanks for the help akabugeyes, ill give it a try in a few minutes here, completely overlooked that.

Cheers,
Ravyn
Ravyn
-SMF Newbie in Training

barramya

Thought I'd reply and say a big thank you to all of you guys in the topic who have advised :) helped me out loads for my site.

Cheers
S

Ravyn

Akabugeyes,

I tried doing that small edit today, and it still produced the same error messages.
I'm using ssi_menubar(); to display the menubar on my home page, outside of the forums.  ie: www.mysite.com/index.php  rather than www.mysite.com/forums/

The buttons show up and work fine with the exception of those 2 errors.  And when I take the Forum link to the forums of my site at www.mysite.com/forums/ the same added buttons (Forums and Gallery) both appear on the menubar still, and the errors do not appear. 

So perhaps its something with calling on it outside the forums directory? Do I need to alter the code to deal with that?  I even tried hard-coding the word Gallery rather than using the language file, and it still gave me the same error.  So that led me to believe it wasn't an issue with the language call, but the variables that are used in creating the button.  Here is my code again:

  // Show the [forums] button.
  if ($context['user']['is_logged'])
    echo ($current_action == 'forums' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'forums' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '">' , $txt['forums'] , '</a>
</td>' , $current_action == 'forums' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';



Note: This is with the Gallery text hardcoded, still providing the same error.
// Show the [gallery] button.
  if ($context['user']['is_logged'])
    echo ($current_action == 'gallery' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'gallery' ? 'active_back' : 'back' , '">
<a href="http://www.mysite.com/gallery/">Gallery</a>
</td>' , $current_action == 'gallery' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';



  if ($context['current_action'] == 'forums')
    $current_action = 'forums';
  if ($context['current_action'] == 'gallery')
    $current_action = 'gallery';


Thanks for your time,
Ravyn
Ravyn
-SMF Newbie in Training

Ravyn

Sry for the bump, wondering if anyone has any ideas?  Those 2 errors at the top of my main page are driving me nuts  :(
Ravyn
-SMF Newbie in Training

codenaught

Ravyn, have you applied this to another theme by any chance? You shouldn't be getting those errors if you have hardcoded it especially. The ssi menubar function would not cause this error as it calls that function directly.
Dev Consultant
Former SMF Doc Coordinator

Ravyn

Nope, using the default theme, basically unedited besides the changes to add the buttons.

Do I need to define the 2 variables somewhere else in the file maybe?
Ravyn
-SMF Newbie in Training

codenaught

If you didn't edit it through the admin panel are you sure it was uploaded properly? Maybe try uploading the changed file again. Make sure it is being uploaded to Themes/default If that doesn't help you can send me your theme's index.template.php to my email at [email protected] and I can take a look at it if you want.
Dev Consultant
Former SMF Doc Coordinator

Ravyn

I've tried so many different iterations of the code, between changing to hardcoded, adding the single quotes that you told me to, taking them out, etc.  That I'm positive it is uploaded correctly.  I'll send over my template file if you have time to take a peek.  Thanks for the help.  If you need anything else, just email me back.
Ravyn
-SMF Newbie in Training

codenaught

Ravyn, I uploaded the file to my test board theme's default directory and did not get any errors. Can you go to your forum's error log: Admin / Forum Error Log and tell me what the errors look like there, such as if the url for the error is always the same or varies and the line number of the file it is occuring in. I am wondering if for some reason this is just happening on your forum page and not inside the forum itself.
Dev Consultant
Former SMF Doc Coordinator

Ravyn

#196
Thats just it.. the error only appears outside the forums.  On my main page, when I click the link that takes me to my forums, the buttons still appear, but the errors do not.  Perhaps its an error in my index.php for my main page?

Same 2 errors repeated over and over again in the Forum Error Log

Apply Filter: Only show the errors with the same message
8: Use of undefined constant forums - assumed 'forums'
/home/virtual/site45/fst/var/www/html/forums/Themes/default/index.template.php (eval?)
95


Apply Filter: Only show the errors with the same message
8: Use of undefined constant gallery - assumed 'gallery'
/home/virtual/site45/fst/var/www/html/forums/Themes/default/index.template.php (eval?)
96

However, the URL listed for each of the errors in the error log (4+ pages of those 2 errors repeated) is listed for every page I visit within my site.  If I go to the search page, the help page, the admin page, even the Error Log page.. each new page creates another set of those 2 errors in the error log, despite the actual errors not appearing on the page like they do on my main page.

Edit: If it would help, I can setup an administrator account for you on the forums to view the error logs and such.  Let me know, and I'll PM you the login/password for it.
Ravyn
-SMF Newbie in Training

codenaught

Sure you can give me admin access and I can take a look at it.
Dev Consultant
Former SMF Doc Coordinator

Ravyn

Doesn't look like akabugeyes was able to find the problem, wondering if anyone else might have an idea?  I can provide you with any template file you might need, or perhaps its an issue with the index.php of my mainpage?

Thanks in advance.
Ravyn
-SMF Newbie in Training

codenaught

Sorry for the delay. I am still thinking the files contents may still be outdated from the file you have on your computer and what you sent me. Can you download the current file from ftp and check to make sure the changes are in it? As I didn't get the errors you have when I tested the file and what I posted should have fixed it.
Dev Consultant
Former SMF Doc Coordinator

Advertisement: