latest
  • User Guide
  • Developer Guide
  • Cookbooks
  • Best Practices
  • Reference
    • Modules
    • Actions
    • Controllers
    • Filters
    • Tags
    • Global template variables
    • Models
      • m_acl
      • m_acl_rule
      • m_acl_user_group
      • m_admin
      • m_admin_blocks
      • m_admin_config
      • m_admin_identity
      • m_admin_menu
      • m_admin_status
      • m_auth2fa
      • m_authentication
      • m_backup
      • m_backup_revision
      • m_category
      • m_client_local_storage
      • m_client_session_storage
      • m_comment
      • m_config
      • m_content_group
      • m_custom_redirect
      • m_development
      • m_edge
      • m_editor_tinymce
      • m_email_dkim
      • m_email_receive_recipient
      • m_email_status
      • m_facebook
      • m_filestore
      • m_fileuploader
      • m_hierarchy
      • m_identity
      • m_import_csv_data
      • m_l10n
      • m_linkedin
      • m_log
      • m_log_email
      • m_log_ui
      • m_mailinglist
      • m_media
      • m_modules
      • m_mqtt_ticket
      • m_oauth2
      • m_oauth2_service
      • m_predicate
      • m_ratelimit
      • m_req
      • m_rsc
      • m_rsc_gone
      • m_search
      • m_seo
      • m_server_storage
      • m_site
      • m_site_update
      • m_ssl_letsencrypt
      • m_survey
      • m_sysconfig
      • m_template
      • m_tkvstore
      • m_translation
      • m_twitter
    • Validators
    • Notifications
    • Installation requirements
    • Configuration
    • Command-line
    • EDoc reference
  • Glossary
Zotonic
  • Docs »
  • Reference »
  • Models »
  • m_search
  • Edit on GitHub

m_search¶

  • Module: core

The m_search model provides access to different kinds of search queries for searching through models.

Most searches in Zotonic are implemented in the mod_search module, searching through the rsc table in different kinds of ways.

Though, any module can implement a search by observing the search_query notification.

The search module is used inside templates. For example, the following snippet fetches the latest 10 modified pages in the “text” category:

{% for id in m.search[{latest cat="text" pagelen=10}] %}
    {{ m.rsc[id].title }}
{% endfor %}

Another example, searching for a text and requesting the second page with 20 results at a time:

{% for id, rank in m.search.paged[{fulltext text=query_string page=2 pagelen=20}] %}
    {{ m.rsc[id].title }}
{% endfor %}

See also

  • Search
  • pager tag
  • mod_search module
  • Custom search
Next Previous

© Copyright 2009–2017, The Zotonic Project (zotonic.com). Revision cd59134d.

Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: latest
Versions
latest
stable
0.x
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.