NP_CustomQuery.php

General Plugin info
Author: nullibicity
Current Version: 01
Download: -
Code: -
Demo: -
Forum Thread: this forum topic

This plugin lets you run commands on SQL queries via plugin parameters. It might be good for testing out plugin ideas or replacing a set of smaller plugins.

Installing

  1. Copy the code from the forum thread (linked above).
  2. Paste it into a file and save that as NP_CustomQuery.php
  3. Upload the file to your plugin directory at yoursite.com/nucleus/plugins/NP_CustomQuery.php
  4. Install the plugin through the Nucleus admin area.

How to use the plugin

Use this in your skin like this: <%Plugin(CustomQuery, query, command)%>, where query and command are quoted PHP strings (see examples). The command is optional – <%Plugin(CustomQuery, query)%> will just echo the first column returned, followed by a break tag.

Due to the way Nucleus parses plugin parameters – it would be nice if a future version would ignore commas in quotes – commas within the query or command strings must be replaced with ”&#44;”. A few global variables are provided; I wasn't sure which ones might be needed (does Nucleus provide an array of globals like PHP does?). Elements returned by the SQL query can be referenced by index or column name, e.g., $row[0] or $row[ititle].

Available SkinVars and/or TemplateVars

Number of Members:

<%Plugin(CustomQuery,”SELECT count(mnumber) FROM ”.sql_table('member'))%>

Member List:

<%Plugin(CustomQuery,”SELECT mname&#44;mrealname FROM ”.sql_table('member').” ORDER BY mname”, echo “$row[mname] ($row[mrealname])<br />”;)%>

Number of Published Entries in Current Blog:

<%Plugin(CustomQuery,”SELECT count(inumber) FROM ”.sql_table('item').” WHERE iblog=”.$blog→getID().” AND idraft=0 AND itime⇐”.mysqldate($blog→getCorrectTime()))%> Alphabetical List of Published Entries in Current Blog:

<%Plugin(CustomQuery,”SELECT ititle&#44;inumber FROM ”.sql_table('item').” WHERE iblog=”.$blog→getID().” AND idraft=0 AND itime⇐”.mysqldate($blog→getCorrectTime()).” ORDER BY ititle”, echo ”<a href=\””.$blog→getURL.createItemLink($row[inumber]&#44; ).”\”>$row[ititle]</a><br />”;)%> Random Entry: <%Plugin(CustomQuery,”SELECT ititle&#44;inumber FROM ”.sql_table('item').” WHERE iblog=”.$blog→getID().” AND idraft=0 AND itime⇐”.mysqldate($blog→getCorrectTime()).” ORDER BY rand() LIMIT 1”, echo ”<a href=\””.$blog→getURL.createItemLink($row[inumber]&#44; ).”\”>$row[ititle]</a><br />”;)%>

Options

  • Not available in version 0.1

Tips and Tricks

Wishlist

Bugs

History

  • [Version 0.1, released August 7, 2004 ]
customquery.txt · Last modified: 2006/08/24 21:54 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki