-
-
Save Realetive/caebdd2f3d279507b046 to your computer and use it in GitHub Desktop.
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 | |
/* | |
Output filter to retrieve names of TVs from a list of TV ids | |
[email protected] | |
Idea: | |
Use it with toogleTVSet plugin (included below) to handel different template options. | |
Usage: | |
This is a simple output filter. | |
You can use it in snippets like getResources or pdoTools to add TVs to your query: | |
Example: | |
&includeTVs=`[[*Header:getTVNames]]` | |
*/ | |
$tvNames = array(); | |
$tvIds = explode(',' ,$input); | |
foreach($tvIds as $tvId){ | |
$tv = $modx->getObject('modTemplateVar', $tvId); | |
$tvNames[] = $tv->get('name'); | |
} | |
$tvNames = implode(',',$tvNames); | |
return $tvNames; |
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 | |
/* | |
toggleTVSet plugin for modx v0.0.4 (2015-03-06 10:31) | |
[email protected] | |
Changelog: | |
----------------------------- | |
v0.0.1 Initial release | |
v0.0.2 Corrected cut and paste mishap | |
v0.0.3 More cut and paste mishap (don't work in multiple tabs...) | |
v0.0.4 Minor changes to js to clean up code. New instructions | |
Todo: | |
----------------------------- | |
Add iterator to handle more than one group of TV Sets. | |
Usage: | |
------------------------------ | |
1. Add plugin to modx manager. | |
2. Check OnDocFormPreRender Event | |
3. Setup Header TVs (Example): | |
* Standard_Headline (4) | |
* Jumbotron_BG_Color (5) | |
* Jumbotron_BG_Image (6) | |
* Jumbotron_RTE (7) | |
* Carousel_MIGX_TV (8) | |
* Cover_Background_Image (9) | |
* Cover_RTE (10) | |
4. Setup Select TV used for picking header type: | |
* Name: Header | |
* Type: Single Select TV | |
* Input Option Values: "Standard==4||Carousel==8||Cover==9,10||Jumbotron==5,6,7" | |
* Allow blank: false | |
* Enable typeahead: false | |
* Move it to the very top of your List of TVs | |
5. Done! | |
*/ | |
$selectTV = "tv11"; // Add the id of your Header Single Select Here | |
/* No changes below this line. */ | |
$js = " | |
Ext.onReady(function () { | |
function toggleTVSet(tvs,displayValue){ | |
for(x in tvs){ | |
if (typeof tvs[x] !== 'function') { | |
var tv = Ext.get('tv' + tvs[x] + '-tr'); | |
tv.setStyle('display',displayValue); | |
} | |
} | |
console.log('toggleTVSet triggered tvs(' + tvs + ') set to display: ' + displayValue ); | |
} | |
Ext.getCmp('modx-resource-tabs').on('tabchange',function(e){ | |
if(e.getActiveTab().id == 'modx-panel-resource-tv'){ | |
var selectTV = Ext.getCmp('".$selectTV."'); | |
var hideTVs = selectTV.store.data.keys.join().split(',') | |
var showTVs = selectTV.getValue().split(',') | |
toggleTVSet(hideTVs , 'none'); | |
toggleTVSet(showTVs , 'block'); | |
selectTV.on('select',function(selectTV){ | |
hideTVs = selectTV.store.data.keys.join().split(',') | |
showTVs = selectTV.getValue().split(',') | |
toggleTVSet(hideTVs , 'none'); | |
toggleTVSet(showTVs , 'block'); | |
}); | |
} | |
}); | |
}); | |
"; | |
$modx->regClientStartupHTMLBlock('<script>'.$js.'</script>'); | |
return; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment