Reply to thread

There's a number of edge cases that can profit from this, such as iterating over content ids without actually having verified that the content ID exists. You can do this if you know a maximum ID, but don't want to look up all intermediate IDs and don't explicitly want to care if there's any holes in your ID list, or even to simplify fetching all existing IDs to just fetching the maximum ID and then just iterating over all.


Basic example:

[CODE="php"]

$viewableIds = [];

for($i = 0; $i <= $maxContentId; $i++) {

    $viewableIds[] = \XF::visitor()->hasContentPermission($contentType, $i, 'view');

}


// Proceed to fetch content with these IDs, or store IDs in cache for later fetching[/CODE]


Back
Top Bottom