vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Help Please:- Displaying a CMS Widget in a Pop Up Window (https://vborg.vbsupport.ru/showthread.php?t=271367)

B16MCC 10-04-2011 06:35 AM

Help Please:- Displaying a CMS Widget in a Pop Up Window
 
1 Attachment(s)
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.

https://vborg.vbsupport.ru/attachmen...1&d=1317717301

So, I've made a custom template and created the link to show the template page as a pop up, this is shown below.

https://vborg.vbsupport.ru/attachmen...1&d=1317717301

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.

Lynne 10-04-2011 03:07 PM

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.

B16MCC 10-04-2011 03:39 PM

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 ?

Lynne 10-04-2011 04:50 PM

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.

B16MCC 10-04-2011 05:22 PM

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

?>


B16MCC 10-05-2011 06:10 PM

Anyone got any ideas please ?

Lynne 10-05-2011 09:21 PM

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.

B16MCC 10-06-2011 11:38 AM

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

Lynne 10-07-2011 12:16 AM

Glad you finally got it. :)

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


All times are GMT. The time now is 03:41 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01720 seconds
  • Memory Usage 1,746KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete