Looking for a developer to fix the articles plugin

Hi everyone, I am looking for a modx developer to fix an issue with Articles.

The plugin automatically generate pages such as Author Page and the Tags Pages. But there is an important SEO issue with this:

Tag and Author pages are using the same title <title>, [[*longtitle]] and [[*pagetitle]] as the blog home page.

Ideally,
Author page should be like: “Articles by author
Tag page should be like: “Tag: TagName

The issue might actually come from getPage and getArchives plugins ( see here )

You will be pushing the fix directly to github ( I have open this issue here )

I also wanted to say is that you will also be helping the modx community by helping fixing the plugin! There are other people using articles ( I’m sure I’m not the only one :slightly_smiling_face: ).

Please, I would appreciate if you could make a precise offer ( how long and how much ).

P.S. If other people using articles are interested in fixing other issues as well ( there are a few on github ), we could set a crowfunding ( just an idea ).

If your problem is just, that all the pages (blog, author page, tag page) use the same template, then maybe you can add a snippet to this template that changes the output depending on the request variables that are present. Something like this may work:

Container template:

...
<title>[[!getPageTitle? &pagetitle=`[[*pagetitle]]`]]</title>
...

Snippet “getPageTitle”:

<?php
if (isset($_GET["tag"])){
    return "Tag: " . filter_var($_GET["tag"], FILTER_SANITIZE_STRING);
} else if (isset($_GET["arc_author"])){
    return "Articles by " . filter_var($_GET["arc_author"], FILTER_SANITIZE_STRING);
} else {
    return $pagetitle;
}
2 Likes

Hi @halftrainedharry thanks for your suggestion, I’ll try it and get back to you.

@joshualuckers do you think this could be implemented to articles ?

Hi @halftrainedharry , I have tried your solution and it seems to be working great! That’s amazing.

I have 2 questions though:

  • Is there a way to call the snippet cached ?
  • Would you be interested in implementing your solution to articles github page ? ( I would happily make a donation to your paypal account )

Thanks a lot anyways.

No. The output of the snippet depends on the request parameters that change between requests. This can’t be cached. But these few lines of codes shouldn’t take much time to execute.

The advantage of this approach is, that it can be implemented without changing the code of the Articles extra.

Honestly I’m not that familiar with the Articles source code and there is probably a better way to implement this. In my opinion it’s better to let the creator of the extra come up with a definitive solution and use this workaround in the meantime.

Here is an extended version of the snippet:

<?php
$title = $pagetitle;
$mode = 'normal';
$tag = '';
$username = '';

if (isset($_GET["tag"])){
    $mode = 'tag';
    $tag = filter_var($_GET["tag"], FILTER_SANITIZE_STRING);
    $title = "Tag: " . $tag;
} else if (isset($_GET["arc_author"])){
    $mode = 'author';
        
    //get username from database
    $user = null;
    $userprofile = null;
    $userPk = $this->xpdo->sanitizeString($_GET['arc_author']);
    if (function_exists('filter_var')) {
        $userPkNum = filter_var($userPk, FILTER_VALIDATE_INT);
    } else { 
        $userPkNum = intval($userPk); 
    }
    if ($userPkNum == 0) {
        $user = $this->xpdo->getObject('modUser', array('username' => $userPk));
    } else {
        $user = $this->xpdo->getObject('modUser', array('id' => $userPkNum));
    }
    
    if ($user){
        $userprofile = $user->getOne('Profile');
    }
    if ($userprofile) {
        $username = $userprofile->get('fullname');
    } else {
        $username = $userPk; //not in database
    }

    $title = "Articles by " . $username;
}

$modx->setPlaceholder('my.title', $title);
$modx->setPlaceholder('my.mode', $mode);
$modx->setPlaceholder('my.tag', $tag);
$modx->setPlaceholder('my.username', $username);
return '';

The snippet now creates placeholders (instead of returning the title) that can then be used in the template. It also returns the fullname of the user (instead of the username). Just call the snippet once uncached in the template. And maybe adjust the snippet to your specific needs.

Placeholders:

  • [[!+my.title]] → The page title as before (<title>[[!+my.title]]</title>)
  • [[!+my.tag]] → The current value of the tag (or '')
  • [[!+my.username]] → The current fullname of the user (or '')
  • [[!+my.mode]] → The values ‘normal’, ‘tag’ or ‘author’ depending on the request parameters. Can be used for output modifiers in the template:

[[!+my.mode:select=`normal=[[*pagetitle]]&tag=Tag: [[!+my.tag]]&author=Articles by [[!+my.username]]`]]

4 Likes

Hi @halftrainedharry again thanks a lot for your help.

I actually realised this would be fairly easy to implement into articles.
All the template/snippets are stored here:

I’m gonna try to submit your solution and see how it goes.