Page List Block suddenly result ins error

Permalink
Hello,

the following code used to work:

function topic_filtered_articles($c, $ParentID, $title,$typ,$nummi,$template,$truncateChars = '60') {
    $attributeKey = CollectionAttributeKey::getByHandle('blog_entry_topics');
    $akHandle = $attributeKey->getAttributeKeyHandle();
    $topics = $c->getAttribute($akHandle);
    $topicsID = $topics[0]->treeNodeID;
    $page_list_block = BlockType::getByHandle('page_list');
    $page_list_block->controller->set("pageListTitle",$title);
    $page_list_block->controller->cThis = '0'; // display pages under the current page (I think) - 0 = no, 1 = yes
    $page_list_block->controller->cParentID = $ParentID; // if another page enter its ID (cid) - 0 must be entered above for cThis
    $page_list_block->controller->ptID = $typ; // only show pages of a particular type(collection Type ID)
    $page_list_block->controller->num = $nummi; // amount to display on a single page
    $page_list_block->controller->orderBy = 'chrono_desc'; // display_asc = Display order ascending, display_desc = Display order descending, chrono_asc = Publish date, alpha_asc = By name ascending, alpha_desc = By name descending
    $page_list_block->controller->rss = '0'; // provide a RSS feed of the pages - 0 = no, 1 = yes
    $page_list_block->controller->displayFeaturedOnly = '0'; // displays only pages with an attribute of is_featured uses a boolean value - 0 = no, 1 = yes
    $page_list_block->controller->displayAliases = '0'; // 0 = no, 1 = yes


Since the upgrade to version 8.2.1 the last line result in the error

"Call to a member function getInstance() on null"

Can anybody help?

Thank you!

 
JohntheFish replied on at Permalink Reply
JohntheFish
What version did you upgrade from?
axelbenz replied on at Permalink Reply
Hi,

Thank you! ... sombody else upgraded, I was called to help, because I was administering the site earlier ... but that's just to apologize, because I realized that the version the were upgrading from was:

5.7.5.13

Best Regards,
Axel
JohntheFish replied on at Permalink Reply
JohntheFish
Some things to think about (not a solution)
-There were big changes in the way attributes worked for v8, some breaking.
- Where does $template come from?

If you enable the debug setting in the dashboard, you may get a whoops trace for the error.
axelbenz replied on at Permalink Reply
Thank you! I will do that.

In the meantime:

$tempate is a string
""templates/ausbildung_topic_filtered""
which refers to a directory created under application/blocks/page_list

Maybe this gives a hint.

Best Regards,

Axel
axelbenz replied on at Permalink Reply
Hello,

so with the debug settings, I could narrow it down to here:

$subtitle_area = new Area('subtitle');
                $subtitle_blocks = $subtitle_area->getAreaBlocksArray($page);
                $subtitle_block = $subtitle_blocks[0];
                $description = strip_tags($subtitle_block->getInstance()->getContent());


Maybe here something has changed with the system calls?
Gondwana replied on at Permalink Reply
Gondwana
I'd be checking to see if $page has been defined (ie, not null). Under some circumstances it is; under other circumstances, it isn't.
axelbenz replied on at Permalink Reply
Thank you,

$page ist $pages[0], where $pages ist just used without initalization in a view.php file. This might be the problem, for as I understand, global variables have been banned - which is very reasonable.

Does anybody know how the $pages array can be initialized properly?

Best Regards,

Axel
Gondwana replied on at Permalink Reply
Gondwana
Have a look at the discussion at the bottom of:
https://documentation.concrete5.org/developers/working-with-blocks/c...

I don't know if it applies to your context, but it should be pretty robust.
axelbenz replied on at Permalink Reply
Hi!
That's a good starting point - in my special case, I need not only the current page, but all pages - they are iterated and searched for keywords (for automatic cross-linking) - is ther also a function to get all the pages?

Best Regards,

Axel