Back to ProBlog Support

michael21172
michael21172

We have a ProBlog list component with the following URL structure: /news/:filter?/:slug?

If we hit /news/tag/billing then the component is loading posts based on tag name and not tag slug:

$tag = TagModel::where('name', '=', $slug)->first();
  if($tag){
    return $tag->posts()->paginate($this->property('postsPerPage'));
}

It appears there is some code to sort out spaces and dashes just above:

$slug = $slug;
$slug = strtolower($slug);
$slug = str_replace('-',' ',$slug);
$slug = str_replace('%20',' ',$slug);

Therefore this works so long as the tag slug basically the same as the tag name but with hyphens instead of spaces. If, however, I have a tag name of 'Billing' and tag slug of 'billing-tag' then the above does not work.

I believe the code should be updated to not manipulate the slug by trying to convert it back into the name and instead just query the tags based on slug:

$tag = TagModel::where('slug', '=', $slug)->first();
  if($tag){
    return $tag->posts()->paginate($this->property('postsPerPage'));
}

This may of course have adverse side effects for other filtering types.

Last updated

ChadStrat
ChadStrat

yeah....I must have been smoking crack when I wrote that. hrmmmm. Let me look into that. Thanks for reporting that.

ChadStrat
ChadStrat

Corrected. Please update to v3.5.0. Also, please make sure you read through the documentation very carefully.

michael21172
michael21172

Brilliant, thanks for a speedy fix.

1-4 of 4