Created
January 30, 2010 15:24
-
-
Save deckchairhq/290593 to your computer and use it in GitHub Desktop.
CakePHP helper for InlineJS (Facebook FBML Tab Page Requirement)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class InlinejsHelper extends AppHelper { | |
var $jsSubFolder = 'fbml'; | |
function renderGeneric() { | |
$genericScript = 'fbmlgeneric.js'; | |
$genericjs = new File(JS . $this->jsSubFolder . DS . $genericScript); | |
$output = '// - Generic Scripts:' . "\n"; | |
$output .= $genericjs->read(); | |
return $this->output( $output ); | |
} | |
function renderSpecific($viewName) { | |
$specificjs = new Folder(JS . $this->jsSubFolder . DS . $viewName . DS); | |
list($folders, $files) = $specificjs->read(); | |
$output = '// - Specific Scripts:' . "\n"; | |
foreach ($files as $file) { | |
$jscode = new File($specificjs->path . $file); | |
$output .= '// -- Script: ' . $viewName . DS . $file . "\n"; | |
$output .= $jscode->read() . "\n"; | |
} | |
return $this->output( $output ); | |
} | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!! Usage In View !! | |
<script> | |
<!-- | |
<?php echo $inlinejs->renderGeneric(); ?> | |
<?php echo $inlinejs->renderSpecific(); ?> | |
//--> | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment