TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

March 29, 2024, 10:59:33 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,106
  • Total Topics: 21,213
  • Online today: 358
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online

"recent Topic" Block "problem" - 8: Undefined variable: settings

Started by sangham.net, April 24, 2013, 07:03:18 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

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

Freddy

Is the block working as it should ?


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

global $context, $modSettings, $txt;

to

global $context, $modSettings, $txt, $settings;

sangham.net

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

IchBin

$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;

sangham.net

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

sangham.net

I looked at the file (english), TPortal.english-utf8.php and as you assumed, there is no $settings within it.

*/

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
<?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

<?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:

<?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

sangham.net

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

IchBin

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.

sangham.net

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

sangham.net

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));
}


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

IchBin

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.

sangham.net

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

IchBin

Change
global $context, $modSettings, $txt;

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

sangham.net

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

Freddy


sangham.net

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