Skip to content

Instantly share code, notes, and snippets.

@adamthebig
Created February 13, 2016 18:54
Show Gist options
  • Save adamthebig/84f2dd12435e1a5886f1 to your computer and use it in GitHub Desktop.
Save adamthebig/84f2dd12435e1a5886f1 to your computer and use it in GitHub Desktop.
Craft request cheat sheet
{# Properties #}
{{ craft.request.firstSegment }}
{{ craft.request.isAjax }}
{{ craft.request.isLivePreview }}
{{ craft.request.isSecure }}
{{ craft.request.lastSegment }}
{{ craft.request.pageNum }}
{{ craft.request.path }}
{{ craft.request.segments }}
{{ craft.request.serverName }}
{{ craft.request.url }}
{# Methods #}
{{ craft.request.isMobileBrowser() }}
{{ craft.request.isMobileBrowser(true) }} {# includes tablets #}
{{ craft.request.getCookie( name ) }}
{{ craft.request.getFirstSegment() }}
{{ craft.request.getLastSegment() }}
{{ craft.request.getPageNum() }}
{{ craft.request.getPath() }}
{{ craft.request.getSegment(n) }}
{{ craft.request.getSegments() }}
{{ craft.request.getServerName() }}
{{ craft.request.getUrl() }}
{{ craft.request.getPost(name) }} {# Returns a parameter from the POST data. #}
{{ craft.request.getQuery(name) }} {# Returns a parameter from the query string. #}
{{ craft.request.getParam(name) }} {# Returns a parameter from either the query string or POST data. #}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment