You are here

function querypath_examples_show_sticky_nodes in QueryPath 6

Same name and namespace in other branches
  1. 7.3 querypath_examples.module \querypath_examples_show_sticky_nodes()
  2. 7.2 querypath_examples.module \querypath_examples_show_sticky_nodes()
1 string reference to 'querypath_examples_show_sticky_nodes'
querypath_examples_menu in ./querypath_examples.module
Implements hook_menu();

File

./querypath_examples.module, line 116
The main file for querypath_examples.

Code

function querypath_examples_show_sticky_nodes() {
  $out = '<h2>' . t('List of nodes marked sticky') . '</h2>';
  $out .= '<p>' . t('Display a list of sticky nodes. This combines a database query with some basic HTML generation.') . '</p>';
  $sql = 'SELECT title FROM {node} WHERE sticky = 1';
  $ul = qp('<?xml version="1.0"?><ul></ul>')
    ->query($sql)
    ->withEachRow()
    ->appendColumn('title', '<li/>')
    ->top()
    ->html();
  $code = '<?php
    $sql = \'SELECT title FROM {node} WHERE sticky = 1\';
    $ul = qp(\'<?xml version="1.0"?><ul></ul>\')
      ->query($sql)
      ->withEachRow()
      ->appendColumn(\'title\', \'<li/>\')
      ->top()
      ->html();
  ?>';
  $out .= $ul;
  $out .= '<h2>' . t('The Code:') . '</h2>';
  $out .= highlight_string($code, TRUE);
  $out .= '<h2>' . t('References:') . '</h2>';
  $out .= l('The QueryPath API', 'http://querypath.org');
  return $out;
}