So my problem is I have a Snippet I created for a website and it needs to be able to have two different sizes; the default size for video and the ’small’ size for the same video on a different page.
<?php
// URL of Video
// Default:
// To change, use vid
// [[NewsVideo?vid=7V5njXJt3H8]]
$vidURL = '';
// Width of Video
// Default: 640
// To change, use LIn_width
// [[NewsVideo?LIn_width=853]]
$vidWidth = 640;
// Height of Video
// Default: 385
// To change, use LIn_height
// [[NewsVideo?LIn_height=505]]
$vidHeight = 385;
// Use snippet call defined variables if set
$vidURL = (isset($vid))? $vid : $vidURL ;
$vidWidth = (isset($LIn_width))? $LIn_width : $vidWidth ;
$vidHeight = (isset($LIn_height))? $LIn_height : $vidHeight ;
// Initialize output
$output = '';
// Get Page
$curPage = $_GET['q'];
// Check Page, if not new page, Resize to 285 x 171 pixels
if($curPage == '') {
$vidWidth = 285;
$vidHeight = 171;
}
// Output
if(strlen($vidURL > 0)) {
$output .= '<object width="' . $vidWidth . '" height="' . $vidHeight . '"><param name="movie" value="http://www.youtube.com/v/' . $vidURL . '&hl=en_US&fs=1?rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' . $vidURL . '&hl=en_US&fs=1?rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' . $vidWidth . '" height="' . $vidHeight . '"></embed></object>';
} else {
$output .= '<p><b>Video Not Found</b></p>';
}
return $output;
?>
I’m not a web expert, so if methods here are wrong you can correct if you wish (and I’ll probably fix them), but that’s not why I’m here.
The $_GET function I’m using works fine
only after I save the snippet. As soon as I edit the resource and save it (even if not changes were made), the get function won’t work. I know this because I had the output also printing the array of print_r($_GET) and just printing $curPage and they would both show blank (or as unbound). As soon as I went in, edited the snippet (even if no changes) and saved it, reloaded the page, everything worked like normal.
My URL’s are set up as semi-friendly, so /?q=xxxxxx where xxxxxx is the longtitle of the page (in my case, /?q=race-update-73110 is the page I have been testing on.
I’m just confused as to why MODx seems to not be passing (or able to retrieve) the ’q’ variable from the URL after I update a resource (even if I ctrl + refresh, go to other pages and come back, etc)
EDIT:
// Get Page
$curPage = $_GET['q'];
// Check Page, if not new page, Resize to 285 x 171 pixels
if($curPage == '') {
$vidWidth = 285;
$vidHeight = 171;
}
because the home page is the only page without /?q= in its URL (and the only page the small video is displayed on)
If there is a way to determine the Parent page (all news stories are stored in the parent ’News’, all press stories are stored in the parent ’Press’ I would
love to know how to do that as well, that way I can use the same snippet for both pages (though I guess I could anyways)