سؤال

I want to add META KEYWORDS into my Resources via my MODx Installation, but cannot, for the life of me find where the default MODx Template Tag is to insert META KEYWORDS.

Thank you, Aaron

هل كانت مفيدة؟

المحلول

There's no thing like a pre-built place for meta-tags in modX. You start with a white page and build the whole templating system on your own. This (among other things) is what makes modX a distinct Content Management Framework (CMF) instead of a plain Content Management System (CMS).

For you, this means, that there are several ways to archieve what you want to do:

a. You might use a pre-built extra to handle meta keywords for you. For modX Revolution the best one for your problem would probably be MetaFormat, that you can install from package management. You can find a detailed description on what this is exactly and what to do on their project page.

b. A more custom way to do this (and the way that I usually prefer) is using custom template variables to have all data just the way you want it to be, instead of relying on some third-party extra. For your case of meta-tags, it would be pretty simple: Create a new template variable (let's call it 'metaKeywords') of type 'text' or even better auto-tag. Configure template access so that all of your templates use this variable. You can find out how to do all of this in the modX manual.

In your template files you can then just use something like this in the head-section:

<meta name="keywords" content="[[*metaKeywords]]">

If you want to have default keywords in case the user doesn't enter keywords for a specific ressource, you can use an output filter like this.

<meta name="keywords" content="[[*metaKeywords:default=`keyword1, keyword2, keyword3`]]">

You should delve a little more in the manual on your own and once you get it, I promise you, you will love the power of custom template-variables. So if you want to work with modX a lot, you should try the second way instead of using a third-party solution.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top