The Arcive of vBulletin Modifications Site. |
|
|
#1
|
|||
|
|||
|
Hi guys, I've taken on a little project that has taught me quite a lot so far but now I'm a little stuck.
I've written a php direct exec widget and have it displayed on my CMS. It simply takes all the mp3 file names from a given folder on the server and lists them as the $output. I then use the yahoo player to turn them into links. This is all done and working. What I'd like to do is to replace the widget with a link on my CMS that then shows this output in a pop up window. The image below is what it look like so far on my CMS. So, I've made a custom template and created the link to show the template page as a pop up, this is shown below. So basically what I'm asking is, how do I move the output from the widget so that its displayed in my pop up window. I hope I've explained myself adequately. Thanks for your time. |
|
#2
|
||||
|
||||
|
I think you'd need to move the php for the widget into it's own php page. You may have to change it a bit and echo instead of putting it into a variable to output (although I guess you can just echo the variable at the end). Then write the javascript for the popup that points to that php page.
|
|
#3
|
|||
|
|||
|
Thanks for the tip Lynne. I've tried making a custom php page, but I'm struggling positioning the output from my code. The page renders just fine, but my custom php output is at the top of the page . How would I position it under the navbar for example ?
|
|
#4
|
||||
|
||||
|
That is hard to say since you haven't posted the code. Post the code, using the code tags, so that I may see what is going on.
|
|
#5
|
|||
|
|||
|
Ok Lynne here's what I've got so far.
I created a template called custom_jukebox Code:
{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml"<vb:if condition="$vboptions['enablefacebookconnect']"> xmlns:fb="http://www.facebook.com/2008/fbml"</vb:if> dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
<head>
{vb:raw headinclude}
<title>{vb:raw vboptions.bbtitle}</title>
<vb:if condition="$vboptions['storecssasfile']">
{vb:cssfile forumhome-rollup.css}
<vb:else />
{vb:cssfile forumbits.css,forumhome.css,widgets.css,sidebar.css,options.css,tagcloud.css}
</vb:if>
<!--[if lt IE 8]>{vb:cssfile forumbits-ie.css,sidebar-ie.css,options-ie.css}<![endif]-->
<vb:if condition="$show['sidebar']">
<script type="text/javascript" src="{vb:stylevar yuipath}/animation/animation-min.js?v={vb:raw vboptions.simpleversion}"></script>
<script type="text/javascript">
var sidebar_align = '{vb:raw show.sidebarposition}';
var content_container_margin = parseInt('{vb:math {vb:stylevar forum_sidebar_width}+{vb:math {vb:stylevar padding}*2}}');
var sidebar_width = parseInt('{vb:stylevar forum_sidebar_width}');
</script>
<script type="text/javascript" src="{vb:raw vboptions.bburl}/clientscript/vbulletin-sidebar.js?v={vb:raw vboptions.simpleversion}"></script>
</vb:if>
{vb:raw headinclude_bottom}
</head>
<body>
{vb:raw header}
{vb:raw navbar}
<div class="cms_widget">
<div class="block">
<div class="cms_widget_header widget_header">
<h3><img src="{vb:stylevar imgdir_siteicons}/php.png" alt="" /> {vb:raw title}</h3>
</div>
<div class="cms_widget_content widget_content">
{vb:raw output}
</div>
</div>
</div>
{vb:raw footer}
</body>
</html>
I also created a new php file called jukebox.php Code:
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'jukebox');
define('CSRF_PROTECTION', true);
// change this depending on your filename
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();
// get special data templates from the datastore
$specialtemplates = array();
// pre-cache templates used by all actions
$globaltemplates = array('custom_jukebox',
);
// pre-cache templates used by specific actions
$actiontemplates = array();
// ######################### REQUIRE BACK-END ############################
// if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line
// chdir ('/path/to/your/forums');
require_once('./global.php');
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
$navbits = construct_navbits(array('' => 'Mambo Hats Jukebox'));
$navbar = render_navbar_template($navbits);
// ###### YOUR CUSTOM CODE GOES HERE #####
// Define the full path to your folder from root
$path = "./mp3";
// Open the folder
$dir_handle = @opendir($path) or die("Unable to open $path");
// Loop through the files
while ($file = readdir($dir_handle)) {
if($file == "." || $file == ".." || $file == "index.php" )
continue;
echo "<a href=\"/mp3/$file\">$file</a><br />";
}
// Close
closedir($dir_handle);
$pagetitle = 'Mambo Hats JukeBox';
// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######
$templater = vB_Template::create('custom_jukebox');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
print_output($templater->render());
?>
|
|
#6
|
|||
|
|||
|
Anyone got any ideas please ?
|
|
#7
|
||||
|
||||
|
As I said before, you need to output your output to a variable. you cannot echo it. You output it into a variable and then register it for use in the template. You are using echo in your php page. ie.....
not: PHP Code:
PHP Code:
|
|
#8
|
|||
|
|||
|
sorry for being a pain, I understand the difference but I don't know what to add to the template to make it output my variable. Could you expand just a little please ?
--------------- Added [DATE]1317908887[/DATE] at [TIME]1317908887[/TIME] --------------- Lynne, I've done it, thankyou for your help. I also found this which helped me over the final hurdle. https://vborg.vbsupport.ru/showthread.php?t=228078 |
|
#9
|
||||
|
||||
|
Glad you finally got it.
![]() And yes, that is a very good article by Cellarius. |
![]() |
|
|
| X vBulletin 3.8.12 by vBS Debug Information | |
|---|---|
|
|
More Information |
|
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|