Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

August 19, 2022, 09:23:59 PM

Login with username, password and session length
Members
  • Total Members: 3843
  • Latest: Tricky
Stats
  • Total Posts: 193479
  • Total Topics: 21088
  • Online today: 60
  • Online ever: 1035
  • (November 26, 2020, 04:45:12 AM)
Users Online
Users: 0
Guests: 43
Total: 43

Author Topic: "recent Topic" Block "problem" - 8: Undefined variable: settings  (Read 10027 times)

0 Members and 1 Guest are viewing this topic.

Offline sangham.net

  • Jr. Member
  • **
  • Posts: 95
  • Our Community account (till 03/14 used by JohannB)
    • sangham.net
Dear TPortal fans and friends,

I hope I posted it in the right section, if not please apologize.

I had a lot of errors and could now find out that it was caused or caused to came up by a TP standard block called "recent topic"

Code: ("don't use code not sure if ok or not!") [Select]
global $context, $modSettings, $txt;
$context['TPortal']['recentboxnum'] = '15';

if(isset($modSettings['recycle_board']))
$bb = $modSettings['recycle_board'];

$what = ssi_recentTopics($context['TPortal']['recentboxnum'], NULL, NULL, 'array');
$counter=1;
$cmax = count($what);

echo '
<div style="width: 100%; overflow: auto; height: 30ex;">';

foreach($what as $w)
{
echo '
<div class="smalltext"><a href="'.$w['href'].'">' . $w['short_subject'] . '</a></div>
<div class="smalltext">', $txt['by'], ' <b>', $w['poster']['link'], '</b></div>
<div class="smalltext">';
if(!$w['new'])
echo '<a href="'.$w['href'].'"><img border="0" src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" /></a> ';

echo '['.$w['time'].']
</div>';

if($counter != $cmax)
echo '<hr />';
$counter++;
}
echo '
</div>';

The error I got in the error log was:
"8: Undefined variable: settings"
21 File: .../Themes/default/languages/TPortal.german-utf8.php (tp_above sub template - eval?)


May questions - beside the intention to inform and share - are:

  • Is it just a "problem" in our environment (setting, mods, ...see info) or general with this code?
  • Do anybody know a good alternative, or how to change the code, so that it would not cause "troubles".


Thanks a lot in advanced!




______________________________
Link to my forum: sangham dot net
SMF version: SMF ver. 2.0.4
TP version: TP ver. 1.0
Default Forum Language: english
Theme name and version: small layout modifications based core
Browser Name and Version: firefox 18.0.2 (just upload activated while searching for version)
Mods installed: Tagging System2.4.3, Menu Editor Lite    1.0.5, (Add Facebook Like, Tweet, and Google +1 1.0.3a - deinstalled again), Quick Translation 0.8, TinyPortal 1.107, SEO Sitemap 2.2.1, Language Drop Down    1.5.3, KeyCAPTCHA for SMF    2.4, New Hooks 0.2, Login Security 1.0.2.2, SMF Quiz    1.1.0
Line: 21
Truly! So strive to be one of them. Or like to get a random Sutta?
If you like to get involved in helping developing an "Virtual monastery" to make the internet a little more accessible for Monks, Nuns and Ascetics, please feel heartily invited to join our bilingual community at sangham.net

Offline Freddy

  • Moderator
  • *
  • Posts: 1615
    • AiDreams
Re: "recent Topic" Block "problem" - 8: Undefined variable: settings
« Reply #1 on: April 24, 2013, 12:20:07 PM »
Is the block working as it should ?


To try to get rid of the error in the log change :

Code: [Select]
global $context, $modSettings, $txt;
to

Code: [Select]
global $context, $modSettings, $txt, $settings;

Offline sangham.net

  • Jr. Member
  • **
  • Posts: 95
  • Our Community account (till 03/14 used by JohannB)
    • sangham.net
Re: "recent Topic" Block "problem" - 8: Undefined variable: settings
« Reply #2 on: April 24, 2013, 08:54:40 PM »
Thanks for your answer Freddy.

I have already deactivated it. Before, it seemed to work well. It showed topics where presently are new posts.

Thanks for your hint, in regard of the change. Since I am not very familiar with programming, I assume its meant in a kind of log.php file or another php file. Is that right?

Another thing is, that I previously had tried to raise the question on SMF-support forum, as I thought that it is a SMF issue. There I got the hint, that it could be a block that could cause the "problem". So I proved it, by turning on and of all blocks, one after the other and found out that it has troubles with this block.

So now it just seems that two things do not work well together. I hope that does not cause any "We are right and you are wrong" discussions between specialists, as such easy could happen. Maybe there are smooth alternatives.

Thanks a lot for your advices.

Truly! So strive to be one of them. Or like to get a random Sutta?
If you like to get involved in helping developing an "Virtual monastery" to make the internet a little more accessible for Monks, Nuns and Ascetics, please feel heartily invited to join our bilingual community at sangham.net

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: "recent Topic" Block "problem" - 8: Undefined variable: settings
« Reply #3 on: April 24, 2013, 11:09:03 PM »
$settings is a global variable used by SMF and TP. Since it seems to be referencing your German language file, I'd suggest checking that file to see if the $settings variable is inside of it. If it is, add the $settings variable to the global line at the top of the file. If there is no global line, just add this then.

global $settings;

Offline sangham.net

  • Jr. Member
  • **
  • Posts: 95
  • Our Community account (till 03/14 used by JohannB)
    • sangham.net
Re: "recent Topic" Block "problem" - 8: Undefined variable: settings
« Reply #4 on: April 24, 2013, 11:43:36 PM »
Thanks a lot for your suggestion. No, it is not exclusively referring to the German language file:

"8: Undefined variable: settings"
File: .../Themes/default/languages/TPortal.english-utf8.php (tp_above sub template - eval?)
line:: 21


I will look at the files anyway, thanks for the hint.

Truly! So strive to be one of them. Or like to get a random Sutta?
If you like to get involved in helping developing an "Virtual monastery" to make the internet a little more accessible for Monks, Nuns and Ascetics, please feel heartily invited to join our bilingual community at sangham.net

Offline sangham.net

  • Jr. Member
  • **
  • Posts: 95
  • Our Community account (till 03/14 used by JohannB)
    • sangham.net
Re: "recent Topic" Block "problem" - 8: Undefined variable: settings
« Reply #5 on: April 25, 2013, 12:07:31 AM »
I looked at the file (english), TPortal.english-utf8.php and as you assumed, there is no $settings within it.

Code: [Select]
*/

global $txt, $context, $scripturl;

// Navigation... //
// Rev 89

A German file does not exist in the default folder, since the defalt language is English, I guess. So you think it is caused by the "invalide" text php. Maybe I have an old version or would that need to be fixed in all language php's?

Correction, I looked into the folder ../forum/Themes/default/languages/... instead of ...Themes/default/languages/... (although I don't understand its function, of this two different folders)
A file german language file exists here as well as all other language files.

here the english in the theme default folder
Code: [Select]
<?php
/**
 * @package TinyPortal
 * @version 1.0
 * @author IchBin - http://www.tinyportal.net
 * @founder Bloc
 * @license MPL 2.0
 *
 * The contents of this file are subject to the Mozilla Public License Version 2.0
 * (the "License"); you may not use this package except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Copyright (C) 2012 - The TinyPortal Team
 *
 */

global $txt$context$scripturl;

here the german

Code: [Select]
<?php
// Version: 1.0 beta4
// German Translation V. 1.0 by The_Gentleman
// TPortal

// Navigation... //
// Rev 89
$txt['tp-admin9'] = 'TP Downloads';

it seems to miss the global setting total

The Swedish does not seem to have it either:

Code: [Select]
<?php
// Version: 1Beta4; TPortal

// Navigation... //
// Rev 89
$txt['tp-admin9'] = 'Filer';

Truly! So strive to be one of them. Or like to get a random Sutta?
If you like to get involved in helping developing an "Virtual monastery" to make the internet a little more accessible for Monks, Nuns and Ascetics, please feel heartily invited to join our bilingual community at sangham.net

Offline sangham.net

  • Jr. Member
  • **
  • Posts: 95
  • Our Community account (till 03/14 used by JohannB)
    • sangham.net
Re: "recent Topic" Block "problem" - 8: Undefined variable: settings
« Reply #6 on: April 25, 2013, 03:24:14 AM »
I have add the $setting in both English files, once in /forum/Themes/default/languages/... and in ...Themes/default/languages/

Still the error arises as soon as I enable this block. ".../Themes/default/languages/TPortal.english-utf8.php"



Truly! So strive to be one of them. Or like to get a random Sutta?
If you like to get involved in helping developing an "Virtual monastery" to make the internet a little more accessible for Monks, Nuns and Ascetics, please feel heartily invited to join our bilingual community at sangham.net

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: "recent Topic" Block "problem" - 8: Undefined variable: settings
« Reply #7 on: April 26, 2013, 10:20:44 PM »
Turn off the template eval option in SMF Admin > Server settings. This will hopefully show you a different error with a more specific place to find the error.

Offline sangham.net

  • Jr. Member
  • **
  • Posts: 95
  • Our Community account (till 03/14 used by JohannB)
    • sangham.net
Re: "recent Topic" Block "problem" - 8: Undefined variable: settings
« Reply #8 on: April 26, 2013, 10:30:15 PM »
Thanks for your advice, IchBin.

Somebody told me that already, still I am a "chicken" in regard of this as there is a heavy warning sentence to change settings there. That's why I tried to figure it out in any other way first. To turn it on again will be no problem, will it? Sorry for being such a scary chicken.

Truly! So strive to be one of them. Or like to get a random Sutta?
If you like to get involved in helping developing an "Virtual monastery" to make the internet a little more accessible for Monks, Nuns and Ascetics, please feel heartily invited to join our bilingual community at sangham.net

Offline sangham.net

  • Jr. Member
  • **
  • Posts: 95
  • Our Community account (till 03/14 used by JohannB)
    • sangham.net
Re: "recent Topic" Block "problem" - 8: Undefined variable: settings
« Reply #9 on: April 27, 2013, 04:56:00 AM »
Ok, the chicken did it at least. I got this now in the error log, as soon as I enable the block with every page view event (link).

8: Undefined variable: settings
File: .../Themes/default/TPsubs.template.php(127) : eval()'d code
Line: 21


Here also code areas in relation to Line 21 und (127):


Code: ("TPsubs.template.php - line 18 - 30") [Select]
// TPortal searchblock
function TPortal_searchbox()
{
global $context, $txt, $scripturl;

echo '
<form accept-charset="', $context['character_set'], '" action="', $scripturl, '?action=search2" method="post" style="padding: 0; text-align: center; margin: 0; ">
<input type="text" name="search" value="" class="block_search" />
<input type="submit" name="submit" value="', $txt['search'], '" class="block_search_submit" /><br />
<br /><span class="smalltext"><a href="', $scripturl, '?action=search;advanced">', $txt['search_advanced'], '</a></span>
<input type="hidden" name="advanced" value="0" />
</form>';
}

Code: ("TPsubs.template.php - line 120 - 128") [Select]
// php blocktype
function TPortal_phpbox()
{
global $context;

// execute what is in the block, no echoing
if(!empty($context['TPortal']['phpboxbody']));
eval(tp_convertphp($context['TPortal']['phpboxbody'],true));
}

« Last Edit: April 27, 2013, 05:21:55 AM by Johann »
Truly! So strive to be one of them. Or like to get a random Sutta?
If you like to get involved in helping developing an "Virtual monastery" to make the internet a little more accessible for Monks, Nuns and Ascetics, please feel heartily invited to join our bilingual community at sangham.net

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: "recent Topic" Block "problem" - 8: Undefined variable: settings
« Reply #10 on: April 29, 2013, 01:41:55 PM »
This part eval()'d code in your error means that you have some code in a custom php block that has this error in it. You need to find out which block it is, and then post the code of that block here if you don't know how to fix it.

Offline sangham.net

  • Jr. Member
  • **
  • Posts: 95
  • Our Community account (till 03/14 used by JohannB)
    • sangham.net
Re: "recent Topic" Block "problem" - 8: Undefined variable: settings
« Reply #11 on: May 02, 2013, 11:28:41 PM »
Dear IchBin,

It must be in the standard "recent Topic" Block (here:), since it only happens if this block is activated.

Code: ("recent Topic") [Select]
global $context, $modSettings, $txt;
$context['TPortal']['recentboxnum'] = '15';

if(isset($modSettings['recycle_board']))
$bb = $modSettings['recycle_board'];

$what = ssi_recentTopics($context['TPortal']['recentboxnum'], NULL, NULL, 'array');
$counter=1;
$cmax = count($what);

echo '
<div style="width: 100%; overflow: auto; height: 30ex;">';

foreach($what as $w)
{
echo '
<div class="smalltext"><a href="'.$w['href'].'">' . $w['short_subject'] . '</a></div>
<div class="smalltext">', $txt['by'], ' <b>', $w['poster']['link'], '</b></div>
<div class="smalltext">';
if(!$w['new'])
echo '<a href="'.$w['href'].'"><img border="0" src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" /></a> ';

echo '['.$w['time'].']
</div>';

if($counter != $cmax)
echo '<hr />';
$counter++;
}
echo '
</div>';

Thanks for your care.

Truly! So strive to be one of them. Or like to get a random Sutta?
If you like to get involved in helping developing an "Virtual monastery" to make the internet a little more accessible for Monks, Nuns and Ascetics, please feel heartily invited to join our bilingual community at sangham.net

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: "recent Topic" Block "problem" - 8: Undefined variable: settings
« Reply #12 on: May 03, 2013, 09:01:37 AM »
Change
global $context, $modSettings, $txt;

to this:
global $context, $modSettings, $txt, $settings;

Offline sangham.net

  • Jr. Member
  • **
  • Posts: 95
  • Our Community account (till 03/14 used by JohannB)
    • sangham.net
Re: "recent Topic" Block "problem" - 8: Undefined variable: settings
« Reply #13 on: May 03, 2013, 09:13:16 AM »
Everything perfect with this block and error now!

Thank you very much!

Truly! So strive to be one of them. Or like to get a random Sutta?
If you like to get involved in helping developing an "Virtual monastery" to make the internet a little more accessible for Monks, Nuns and Ascetics, please feel heartily invited to join our bilingual community at sangham.net

Offline Freddy

  • Moderator
  • *
  • Posts: 1615
    • AiDreams
Re: "recent Topic" Block "problem" - 8: Undefined variable: settings
« Reply #14 on: May 03, 2013, 09:15:42 AM »
I did say that originally ;)

Offline sangham.net

  • Jr. Member
  • **
  • Posts: 95
  • Our Community account (till 03/14 used by JohannB)
    • sangham.net
Re: "recent Topic" Block "problem" - 8: Undefined variable: settings
« Reply #15 on: May 03, 2013, 09:24:17 AM »
Freddy, No doubt... somehow I thought I had to change anywhere anything special... Right in front of the eye unseen.
Thanks and sorry for not understanding the first answer rightly and causing so much other directions of thought and investigations.

Truly! So strive to be one of them. Or like to get a random Sutta?
If you like to get involved in helping developing an "Virtual monastery" to make the internet a little more accessible for Monks, Nuns and Ascetics, please feel heartily invited to join our bilingual community at sangham.net