# Looking for a developer to fix the articles plugin

**URL:** <https://community.modx.com/t/looking-for-a-developer-to-fix-the-articles-plugin/4569>\
**Category:** Marketplace\
**Created:** [November 3, 2021, 9:38am UTC](https://community.modx.com/t/looking-for-a-developer-to-fix-the-articles-plugin/4569 "2021-11-03T09:38:08Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![carlo\_13](https://community.modx.com/user_avatar/community.modx.com/carlo_13/32/2751_2.png) [@carlo\_13](https://community.modx.com/u/carlo_13)\
**Post date:** [November 3, 2021, 9:38am UTC](https://community.modx.com/t/looking-for-a-developer-to-fix-the-articles-plugin/4569/1 "2021-11-03T09:38:08Z")

</div>

Hi everyone, I am looking for a modx developer to fix an issue with [Articles](https://modx.com/extras/package/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](https://github.com/modxcms/Articles/issues/147#issuecomment-912577119) )

You will be pushing the fix directly to github ( [I have open this issue here](https://github.com/modxcms/Articles/issues/134) )

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 🙂 ).

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 ).

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [November 3, 2021, 11:56am UTC](https://community.modx.com/t/looking-for-a-developer-to-fix-the-articles-plugin/4569/2 "2021-11-03T11:56:25Z")

</div>

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:

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

```

Snippet “getPageTitle”:

```auto
<?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;
}

```

---

<div class="post-metadata">

**Author:** ![carlo\_13](https://community.modx.com/user_avatar/community.modx.com/carlo_13/32/2751_2.png) [@carlo\_13](https://community.modx.com/u/carlo_13)\
**Post date:** [November 3, 2021, 1:32pm UTC](https://community.modx.com/t/looking-for-a-developer-to-fix-the-articles-plugin/4569/3 "2021-11-03T13:32:49Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![carlo\_13](https://community.modx.com/user_avatar/community.modx.com/carlo_13/32/2751_2.png) [@carlo\_13](https://community.modx.com/u/carlo_13)\
**Post date:** [November 3, 2021, 4:13pm UTC](https://community.modx.com/t/looking-for-a-developer-to-fix-the-articles-plugin/4569/4 "2021-11-03T16:13:26Z")

</div>

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](https://github.com/modxcms/Articles) ? ( I would happily make a donation to your paypal account )

Thanks a lot anyways.

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [November 3, 2021, 5:01pm UTC](https://community.modx.com/t/looking-for-a-developer-to-fix-the-articles-plugin/4569/5 "2021-11-03T17:01:42Z")

</div>

> [@carlo\_13](#):
>
> Is there a way to call the snippet cached ?

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.

> [@carlo\_13](#):
>
> Would you be interested in implementing your solution to articles github page ?

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.

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [November 3, 2021, 5:15pm UTC](https://community.modx.com/t/looking-for-a-developer-to-fix-the-articles-plugin/4569/6 "2021-11-03T17:15:59Z")

</div>

Here is an extended version of the snippet:

```auto
<?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]]`]] `

---

<div class="post-metadata">

**Author:** ![carlo\_13](https://community.modx.com/user_avatar/community.modx.com/carlo_13/32/2751_2.png) [@carlo\_13](https://community.modx.com/u/carlo_13)\
**Post date:** [November 4, 2021, 1:29pm UTC](https://community.modx.com/t/looking-for-a-developer-to-fix-the-articles-plugin/4569/7 "2021-11-04T13:29:56Z")

</div>

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:

> **[Articles/core/components/articles/elements at develop · modxcms/Articles](https://github.com/modxcms/Articles/tree/develop/core/components/articles/elements)**
>
> develop/core/components/articles/elements

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

---

<div class="post-metadata">

**Author:** ![carlo\_13](https://community.modx.com/user_avatar/community.modx.com/carlo_13/32/2751_2.png) [@carlo\_13](https://community.modx.com/u/carlo_13)\
**Post date:** [October 12, 2024, 4:18pm UTC](https://community.modx.com/t/looking-for-a-developer-to-fix-the-articles-plugin/4569/8 "2024-10-12T16:18:26Z")

</div>

Hi everyone,

I’m bumping this old topic because I’ve realised there might be a bug with MODX Articles. Basically, you can generate any page you want by adding this URL to any articles-based blog:

`?arc_author=somerandomwords&page=2`

Instead of returning an error page, Articles actually generates these pages.

It gets worse when using the script above, as it displays these random words on the website.

Any ideas on how to fix this?

I was thinking of maybe forcing the script to check for the author or tag existence, but it’s just a temporary fix. **Articles should not be generating these pages.**

* * *

This is the script by @halftrainedharry that I have slightly modified:

getPageTitle

```auto
<?php
if (isset($_GET['tag'])) {
	return 'Tag: ' . htmlspecialchars($_GET['tag'], ENT_QUOTES, 'UTF-8');
} else if (isset($_GET['arc_author'])) {
	return 'Articles by ' . htmlspecialchars($_GET['arc_author'], ENT_QUOTES, 'UTF-8');
} else {
	return htmlspecialchars($pagetitle, ENT_QUOTES, 'UTF-8');
}

```

getPageDescription

```auto
<?php
// Default to the resource description if no specific parameters are found
$description = $description ?: '';

// Check if the 'tag' parameter exists in the URL
if (isset($_GET['tag'])) {
	$description = 'Explore articles tagged with ' . htmlspecialchars($_GET['tag'], ENT_QUOTES, 'UTF-8');
}
// Check if the 'arc_author' parameter exists in the URL
else if (isset($_GET['arc_author'])) {
	$description = 'Read articles written by ' . htmlspecialchars($_GET['arc_author'], ENT_QUOTES, 'UTF-8');
}
// Return the final description
return $description;

```

---

<div class="post-metadata">

**Author:** ![AnyScreenSize](https://community.modx.com/user_avatar/community.modx.com/anyscreensize/32/35_2.png) [@AnyScreenSize](https://community.modx.com/u/AnyScreenSize)\
**Post date:** [October 13, 2024, 4:43pm UTC](https://community.modx.com/t/looking-for-a-developer-to-fix-the-articles-plugin/4569/9 "2024-10-13T16:43:44Z")

</div>

Not sure if Articles is still the way to go for a blog…

For MODX 3+ I would suggest using Collections with PDO Resources and if needed Tagger.

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [October 13, 2024, 6:37pm UTC](https://community.modx.com/t/looking-for-a-developer-to-fix-the-articles-plugin/4569/10 "2024-10-13T18:37:26Z")

</div>

> [@carlo\_13](#):
>
> Instead of returning an error page, Articles actually generates these pages.

Is this really a problem?  
The page outputs a list of articles and with request-parameters for author or tag you can filter this list. If you supply a value that doesn’t exist, then the list is simply empty or the unfiltered list gets returned.

> [@carlo\_13](#):
>
> It gets worse when using the script above, as it displays these random words on the website.

You obviously don’t want to output HTML or JS input from a user directly to your page, but you can achieve that by properly sanitizing the user input.

* * *

What exactly do you want to happen?

- Only show the page if a user exists?
- Or only show the page if an article exists written by this user?

In the first case, you can just check the _modUser_ table (see my code above for the “extended version”) and forward the request to the error page if a corresponding user can’t be found.

In the second case, you’d have to evaluate the output of the _getPage_/_getResources_ call that happens on the page.

---

<div class="post-metadata">

**Author:** ![carlo\_13](https://community.modx.com/user_avatar/community.modx.com/carlo_13/32/2751_2.png) [@carlo\_13](https://community.modx.com/u/carlo_13)\
**Post date:** [January 6, 2025, 2:46pm UTC](https://community.modx.com/t/looking-for-a-developer-to-fix-the-articles-plugin/4569/11 "2025-01-06T14:46:00Z")

</div>

Apologies for my late reply, somehow I missed the notifications.

@AnyScreenSize If I switch to Collection, will I be able to maintain the tags and URL format that were already created by articles ?

@halftrainedharry I managed to make some changes to the snippet, and it seems to have fixed the issue.

---

<div class="post-metadata">

**Author:** ![AnyScreenSize](https://community.modx.com/user_avatar/community.modx.com/anyscreensize/32/35_2.png) [@AnyScreenSize](https://community.modx.com/u/AnyScreenSize)\
**Post date:** [January 6, 2025, 3:02pm UTC](https://community.modx.com/t/looking-for-a-developer-to-fix-the-articles-plugin/4569/12 "2025-01-06T15:02:32Z")

</div>

No problem!

- Tags will be needed to be exported somehow and converted to the more modern Tagger
- URL format should be problem no

---

<div class="post-metadata">

**Author:** ![carlo\_13](https://community.modx.com/user_avatar/community.modx.com/carlo_13/32/2751_2.png) [@carlo\_13](https://community.modx.com/u/carlo_13)\
**Post date:** [January 8, 2025, 8:35am UTC](https://community.modx.com/t/looking-for-a-developer-to-fix-the-articles-plugin/4569/13 "2025-01-08T08:35:33Z")

</div>

Yes, I’ll probably run some tests locally first, from experience, there’s always something that goes wrong 😆. Never make big changes directly on a live website!

But yes, I will check that out.
