Unsorted Code Examples
Please note the following code examples may not have been tested, so results may vary!
Finding the number of pages in a site If you inherit from RWAbstractPlugin then something like the following should work:
int pageCount = [[[self document] allPages] count];
How to notify RapidWeaver the page has changed:
//Marks the current page as changed. [self broadcastPluginChanged]; //Marks all other pages in the site as changed. [self broadcastPluginChangedInvert];
Exporting extra raw html pages into the "files" directory
- (NSString*)tempFilesDirectory
{
return [self tempFilesDirectory:@"RWMyNewPlugin"];
}
- (NSArray *)extraFilesNeededInExportFolder:(NSDictionary*)params
{
NSMutableString *myPageContent = [NSMutableString string];
[myPageContent appendString:@"<b>Hello World!</b>"];
[myPageContent writeToFile:[[self tempFilesDirectory] stringByAppendingPathComponent:@"mypage.php"] atomically:NO encoding:NSUTF8StringEncoding error:nil];
return [self directoryContents:[self tempFilesDirectory]];
//return nil;
}
Exporting extra pages using the selected theme. i.e. contentOnlySubpageWithHTML
- (NSString*)tempFilesDirectory
{
return [self tempFilesDirectory:@"RWMyGreatPlugin"];
}
- (NSArray *)extraFilesNeededInExportFolder:(NSDictionary*)params
{
NSMutableString *myPageContent = [NSMutableString string];
NSMutableArray* extraPages = [NSMutableArray array];
[myPageContent appendString:@"<b>Hello World!</b>"];
[extraPages addObject:[self contentOnlySubpageWithHTML:myPageContent name:@"myPage.php"]];
return [extraPages arrayByAddingObjectsFromArray:[self directoryContents:[self tempFilesDirectory]]];
}
Exporting a flash file:
Code From the forum: http://www.realmacsoftware.com/support/viewtopic.php?id=22363
- (NSArray *)extraFilesNeededInExportFolder:(NSDictionary*)params
{
NSMutableArray *extraFiles;
NSString *flashFile;
NSBundle *localBundle;
// Create our extra file array
extraFiles = [NSMutableArray array];
// Pick up a reference to our plugin bundle
localBundle = [NSBundle bundleForClass:[self class]];
// Export the our flash file from the bundle
flashFile = [localBundle pathForResource:@"myflash" ofType:@"swf"];
[extraFiles addObject:flashFile];
return extraFiles;
}
