News:

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

Main Menu

HTML-layout error in GenericList.template.php

Started by maestrosite.ru, February 13, 2012, 11:21:33 AM

Previous topic - Next topic

maestrosite.ru

Where the Error Occurred

    File: GenericList.template.php
    Line: 86-110,
    Any relevant errors in the SMF error log (if so please post them)?:

1. Start tag for tbody-element print in if-section.
lines: 86-110
Quote
   if (!($header_count < 2 && empty($cur_list['headers'][0]['label'])))
   {
      echo '
         <thead>
            <tr class="catbg">';
...
      echo '
            </tr>
         </thead>
         <tbody>';
   }

2. But end tag have unconditional print (echo without any conditionals)
lines: 139-142:
Quote
   echo '
         </tbody>
         </table>';

Total: if current list have not headers then result layout not valid - missing <tbody>.


Additionally for this function.
Don`t check existing of current list:
lines:17-19
Quote
   // Get a shortcut to the current list.
   $list_id = $list_id === null ? $context['default_list'] : $list_id;
   $cur_list = &$context[$list_id];

May be add something of this :
Quote
if( empty($context['default_list']) )
   retrun;
if( empty($context[$list_id]) )
   retrun;
First of all, sorry for my english. По-русски у меня получается значительно лучше.

Проблема на форуме? Сначала посмотрите лог ошибок вашего форума и лог ошибок сайта (error_log)

You can try other modifications - see demo

emanuele

Hi maestrosite.ru,

thank you for the report.

The first one is for sure a bug.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

emanuele

The second is an assumption in the code (i.e. the code assume the list exists)...maybe some kind of warning if it doesn't?


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

maestrosite.ru

First of all, sorry for my english. По-русски у меня получается значительно лучше.

Проблема на форуме? Сначала посмотрите лог ошибок вашего форума и лог ошибок сайта (error_log)

You can try other modifications - see demo

emanuele

Sorry, I was thinking to another issue and the sentence is not very clear.

I mean that the current code does an assumption: the list exists.
And I agree it's not correct, at least it's not in line with (most of) the other the code in SMF.
What I'm wondering is: is it better to just "return;" or maybe create a sort of error like: "the list doesn't exist"?


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

maestrosite.ru

Of course, better is show error! I'm wrote code only for example.
(And I think best - throw Exception, but is not SMF-way)
First of all, sorry for my english. По-русски у меня получается значительно лучше.

Проблема на форуме? Сначала посмотрите лог ошибок вашего форума и лог ошибок сайта (error_log)

You can try other modifications - see demo

Arantor

The first was fixed in 2.1 some time ago, the second I've just changed in 2.1 to not throw an error (throwing an error of any kind from the template itself would be a bit awkward and inconsistent)

Advertisement: