News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

help with a bit of code please -- isset check

Started by stog, January 06, 2023, 12:52:52 PM

Previous topic - Next topic

stog

hi

got our old forum finally upgraded to 2.13 thx for great software

was worried about the ancient database & loosing folks' posts but all went well

i do though have some article menu areas/links that do still use the old 2.0.19 custom theme via Tiny Portal

they're working ok but throwing up 'Undefined array key errors' in a few parts of the old theme's index template which i thought i'd try fixing by doing a check to see if the array items exist using isset

i saw this bit of code elsewhere & wonder if i can patch it in before?

if (isset($txt['page_created']))
                {


and i want to insert it into
// Show the load time?
    if ($context['show_load_time'])
        echo '
            <br>', $txt['page_created'], $context['load_time'], $txt['seconds_with'], $context['load_queries'], $txt['queries'];

where the array
            <br>', $txt['page_created'], $context['load_time'], $txt['seconds_with'], $context['load_queries'], $txt['queries'];
are all erroring.

I've tried a couple of times & realised i need that closing bracket but don't really know how to do or try this cleanly

any help or advice appreciated from an 'interested in coding but useless' novice

cheers

Sesquipedalian

You can use "&&" to include multiple conditions in the condition clause for the if statement, like this:

    if ($context['show_load_time'] && isset($txt['page_created'], $context['load_time'], $txt['seconds_with'], $context['load_queries'], $txt['queries']))
        echo '
            <br>', $txt['page_created'], $context['load_time'], $txt['seconds_with'], $context['load_queries'], $txt['queries'];
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

stog

that is so helpful thank you very much

stog

unfortunately the page went white, and I'm wondering whether the isset can be set to allow the condition, the operation but not render errors (unlike array_key exists) even if it "isn't"?

thx 4 your help btw

it's probably easier just to copy the content from some of these older theme pages to new articles formed in the upgraded smf/tp installation (they're pages like privacy policy etc so should be quick to copy)

stog

fixed

Even easier than having to copy/paste

TP settings for the article allow you to change the theme to the current curve theme (scroll to bottom in edit)

thx again for the code help -- helps me better understand what's happening

cheers

Advertisement: