Link | google_sitemap |
Author | Jason Huck |
Category | Technical |
Version | 8.x |
License | http://opensource.org/licenses/artistic-license.php |
Posted | 30 Jun 2006 |
Updated | 30 Jun 2006 |
More by this author... |
This is a custom type for generating Google Sitemaps. It contains the following member tags:
->addurl - Used to add a URL node to the map. Per the API, accepts -loc, -lastmod, -changefreq, and -priority. Only -loc is required. For specific usage instructions, refer to the API reference.
->save - Saves a gzip-compressed copy of the map to the provided folder path with the name 'sitemap.gz'. Requires file tags permissions and the [compress_gzip] tag.
->output - Used internally, outputs an XML representation of the sitemap. The onConvert callback calls this tag.
->createnode - Used internally, converts a map of URL parameters into an xml node.
inline( -username='xxxxxx', -password='xxxxxx'); var('mySiteMap') = google_sitemap; $mySiteMap->addurl( -loc='http://www.yahoo.com/blah.html?foo=bar&red=blue', -lastmod=date, -changefreq='always', -priority=1.0 ); $mySiteMap->save(response_path); /inline;
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
define_type( 'sitemap', -namespace='google_', -prototype, -description='Custom type for creating Google Sitemaps.' ); local('urls' = array); define_tag( 'addurl', -req='loc', -type='string', -copy, -opt='lastmod', -type='date', -opt='changefreq', -type='string', -opt='priority', -type='decimal' ); fail_if( (!valid_url(#loc) || #loc->size >= 2048), -1, 'Location must be a valid URL and less than 2048 characters.' ); #loc = encode_xml(decode_xml(#loc)); // avoid double encoding local_defined('lastmod') ? #lastmod->setformat('%Y-%m-%d'); if(local_defined('changefreq')); local('freqs') = array( 'always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never' ); #freqs !>> #changefreq ? #changefreq = null; else; local('changefreq' = null); /if; if(local_defined('priority')); select(true); case(#priority < 0.0); #priority = 0.0; case(#priority > 1.0); #priority = 1.0; case; #priority->setformat( -precision=1); /select; else; local('priority' = 0.5); /if; local('out' = map); #out->insert('loc' = #loc); #out->insert('lastmod' = #lastmod); #out->insert('changefreq' = #changefreq); #out->insert('priority' = #priority); self->urls->insert(#out); /define_tag; define_tag('createnode', -req='in'); local('out') = xml(''); #out->newchild('loc')->addcontent(#in->find('loc')); #in->find('lastmod') != null ? #out->newchild('lastmod')->addcontent(#in->find('lastmod')); #in->find('changefreq') != '' ? #out->newchild('changefreq')->addcontent(#in->find('changefreq')); #out->newchild('priority')->addcontent(#in->find('priority')); return(@#out); /define_tag; define_tag('output'); local('out') = xml('\ \ '); iterate(self->urls, local('i')); #out->addchild(self->createnode(#i)); /iterate; return('\n' + #out); /define_tag; define_tag('onConvert'); return(@self->output); /define_tag; define_tag('save', -req='path'); local('filepath' = #path); #filepath->removetrailing('/')&append('/sitemap.gz'); file_write( #filepath, compress_gzip(self->output), -fileoverwrite ); /define_tag; /define_type;
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft