Sign In
Start Page | Recent Changes | All Pages | Orphan Pages | Junebug Help

Comparing version 3 and version 2

PortRecordTags extends Radiant 0.6+ with tags for displaying database records on "ActiveRecord":http://rubyforge.org/projects/activerecord/ models *without* requiring that a custom tag set be written for each custom model.  I have used RecordTags to render custom models for back-end interfaces I have implemented.

It is important to note that your Radiant instance MUST define the models you plan on accessing.  The following examples use the already-present User model.

Sample usage for displaying a result set formatted as a table:


 

	
		
			
				
				
				
				
			
		
			
				
				
				
				
			
		
		
nameloginupdated atnotes

users returned.

No users have been entered.

Sample usage for displaying a single record:

 
	

There are no notes on this pageuser.

h2. overTag fromReference h3. records Selects a result set of models. Attributes: * model (required) * id * conditions * order * offset * limit These attributes are passed directly to the oldActiveRecord.find wiki:method. The "conditions" attribute does not accept '?' parameters. You will have to pass the actual values. http://dev.radiantcms.org/radiant/wiki/RecordTagsFor example:

 
  ... this format is not yet supported.
h3. if_returned This tag contains the tags/content that will be rendered when a result set is found. h3. unless_returned This tag contains the content that will be rendered when a result set is NOT found. h3. count This empty tag returns the count of records returned. h3. each This tag selects each record in turn for individual rendering. It will contain the 'value', 'if_value', 'unless_value' tags. h3. value This empty tag displays the value of the field named by the "for" attribute.

 
Attributes: * for (required unless already passed in the outer if_value or unless_value tags) h3. if_value This conditional tag renders its contents only if the named value is present (that is, it is NOT empty space or nil). This is useful for conditionally displaying matching labels, line breaks, paragraphs, etc.:

 

Attributes: * for (required) h3. unless_value This conditional tag is the reciprocal of the above, rendering content when the named value is blank. Attributes: * for (required) h3. record Like the 'records' tag however only the first matching record is returned. I anticipate this tag may make greater use of the 'id' attribute for the direct selection of a specific record. Within the record tag are the 'if_value', 'unless_value', and 'value' tags, just as used by 'records'. h2. Warning I released this extension early to meet the demand for this sort of functionality. It is not as robust as I had planned on making it, nor is it in its final form. Tag names and implementations are subject to change. The most needed feature at this point is the custom formatting of values. That is, it would be useful to be able to specify various date formats, currency formats, etc. h2. Acknowledgements Thanks to John Long for creating the incredibly useful Radius which, in itself, makes Radiant an attractive backbone for a website. Thanks to Sean Cribbs for his Radius tutorials.

Back to Page