Override Content

Recently I was working on a portion of a web site that required dynamic menus. However, I needed to override those dynamic menus for certain pages in the web site with custom menus. It is possible to achieve this using typoscript.

The typoscript I created works like this:

  • If content exists in the left column (i.e., styles.content.getLeft), display it
  • If no content exists, display a dynamic menu listing links to all sub-pages of the current page

The whole listing of typoscript in the SETUP section of the template is shown below:


config.xhtml_cleaning = all
config.prefixLocalAnchors = all
config.intTarget = _self
plugin.tx_automaketemplate_pi1 {
  content = FILE
  content.file = fileadmin/template/infosys/template_root.html
  # Define dynamic portions of html template
  elements {
    BODY.all = 1
    BODY.all.subpartMarker = DOCUMENT_BODY
    HEAD.all = 1
    HEAD.all.subpartMarker = DOCUMENT_HEADER
    HEAD.rmTagSections = title
    SPAN.class.depth = 1
    SPAN.class.subtitle = 1
    SPAN.class.rightNav = 1
    DIV.id.quickBlock = 1
    DIV.id.menuBlock = 1
    DIV.id.loginBlock = 1
    DIV.id.mainbar = 1
  }

  # Prefix all relative paths with this value:
  relPathPrefix = fileadmin/template/infosys/
}

# Create default navigation menu
temp.menu_1 = HMENU
temp.menu_1.special = directory
temp.menu_1.special.data = global:id
temp.menu_1.1 = TMENU
temp.menu_1.1 {
  # Normal state properties
  NO.stdWrap.htmlSpecialChars = 1

  # Enable active state and set properties:
  ACT = 1
  ACT.stdWrap.htmlSpecialChars = 1
}

temp.overlayContentLeft = COA
temp.overlayContentLeft {
  10 < styles.content.getLeft
  10.stdWrap.ifEmpty.cObject = COA
  10.stdWrap.ifEmpty.cObject {
    10 = TEXT
    10.data = leveltitle:-1
    10.wrap = <h1> | </h1>
    20 < temp.menu_1
  }
}

# Main TEMPLATE cObject for the BODY
temp.mainTemplate = TEMPLATE
temp.mainTemplate {
  template =< plugin.tx_automaketemplate_pi1
  workOnSubpart = DOCUMENT_BODY
  subparts {
    # Set subtitle
    subtitle = TEXT
    subtitle.data = leveltitle:1
    # Import main page content
    mainbar < styles.content.get
    # Populate site depth path
    depth = HMENU
    depth.special = rootline
    depth.1 = TMENU
    depth.1.NO.linkWrap = | /  |*||*|  |
    # Populate the IT menu
    menuBlock < temp.overlayContentLeft
    # Populate the Quick Links menu
    quickBlock < styles.content.getRight
  }
}

# Main TEMPLATE cObject for the HEAD
temp.headTemplate = TEMPLATE
temp.headTemplate {
  template =< plugin.tx_automaketemplate_pi1
  workOnSubpart = DOCUMENT_HEADER
}

# Default PAGE object:
page = PAGE
page.typeNum = 0
page.config.doctype = xhtml_trans
page.10 < temp.mainTemplate
page.headerData.10  < temp.headTemplate

 

Leave a Reply