Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 10-04-2011, 07:35 AM
B16MCC B16MCC is offline
 
Join Date: Feb 2002
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Help Please:- Displaying a CMS Widget in a Pop Up Window

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.
Attached Images
File Type: png Screen Shot 2011-10-04 at 08.24.46.png (40.8 KB, 0 views)
File Type: jpg Screen Shot 2011-10-04 at 08.29.28.jpg (53.2 KB, 0 views)
Reply With Quote
  #2  
Old 10-04-2011, 04:07 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 10-04-2011, 04:39 PM
B16MCC B16MCC is offline
 
Join Date: Feb 2002
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 ?
Reply With Quote
  #4  
Old 10-04-2011, 05:50 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 10-04-2011, 06:22 PM
B16MCC B16MCC is offline
 
Join Date: Feb 2002
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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());

?>
Reply With Quote
  #6  
Old 10-05-2011, 07:10 PM
B16MCC B16MCC is offline
 
Join Date: Feb 2002
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Anyone got any ideas please ?
Reply With Quote
  #7  
Old 10-05-2011, 10:21 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
echo "<a href=\"/mp3/$file\">$file</a><br />"
but:
PHP Code:
$output .= "<a href=\"/mp3/$file\">$file</a><br />"
then register the variable like you do the otehrs.
Reply With Quote
  #8  
Old 10-06-2011, 12:38 PM
B16MCC B16MCC is offline
 
Join Date: Feb 2002
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #9  
Old 10-07-2011, 01:16 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Glad you finally got it.

And yes, that is a very good article by Cellarius.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:39 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.11335 seconds
  • Memory Usage 2,265KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (2)postbit_attachment
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete