Skip to content
  1. Extras
  2. GoogleSheets
  3. Export
  4. Resources

Resources (modResource) ​

Standard resource fields ​

FieldName
idId resource
pagetitleTitle
longtitleLong title
descriptionDescription
introtextIntro text
templateTemplate (id)
aliasAlias
menutitleMenu title
link_attributesLink attributes
hidemenuHide from menu
publishedPublished
parentParent resource (id)
class_keyResource type
content_typeContent type
content_dispoContent disposition
menuindexMenu index
publishedonDate, when resource was published
pub_datePublish date
unpub_dateUnpublish date
isfolderContainer
searchableSearchable
alias_visibleUse alias in alias path
richtextUse HTML editor
uri_overrideFreeze URI
uriURI
cacheableCached
deletedDeleted
contentContent
context_keyContext
tv1TV with id 1

Field modifiers ​

FieldName
template_nameTemplate (name)
parent_nameParent resource (name)

ms2Gallery ​

NameName
imageslist of images

All image files must be on the server

SEO Tab ​

FieldName
seo.indexSearch engine indexability
seo.followFollow links
searchableInclude in site search. Standard field resource
seo.sitemapInclude in Sitemap.xml
seo.priorityPriority
seo.changefreqContent update frequency
seo.redirect301 redirects
uri_overrideFreeze URL alias for this page. Standard field resource
uriURL to freeze. Standard field resource

SEO Pro ​

FieldName
keywords || seo.keywordsKeywords

Example ​

Export fields: id,pagetitle,description,tv1

Table result:

Table result

System events ​

Class gsResource fires these events:

php
<?php
switch ($modx->event->name) {
  // fetches the list of resources
  case 'gsOnBeforeGetResource':
    // $query - selection query
    // $range - sheet name, where data will be exported
    break;
  case 'gsOnGetResource':
    // $resources - array of resources with all fields
    // $range - sheet name
    break;
}

Examples ​

  1. Select resources with a specific template

    php
    <?php
    if ($modx->event->name == 'gsOnBeforeGetResource') {
      $query->where(array('template' => 3)); // 3  - id template
    }
  2. Change field value publishedon (milliseconds => date)

    php
    <?php
    if ($modx->event->name == 'gsOnGetResource') {
      $modx->event->params['resources'] = array_map(function ($resource) {
        if (!empty($resource['publishedon'])) {
          $resource['publishedon'] = date("d-m-Y",$resource['publishedon']);
        }
        return $resource;
      }, $resources);
    }