Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-18-2012, 06:54 PM
cloferba cloferba is offline
 
Join Date: Apr 2009
Posts: 437
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Use of output on php code

I?ve read this manual (https://www.vbulletin.com/forum/show...L-or-PHP-Block) but I don?t understand very well how to implement this on my custom code.

I need to show this php code on a block, but I don?t know how to use $output variables:
Code:
<?php

// Each sponsor is an element of the $sponsors array:

$sponsors = array(
	array('facebook','The biggest social network in the world.','http://www.facebook.com/'),
	array('adobe','The leading software developer targeted at web designers and developers.','http://www.adobe.com/'),
	array('microsoft','One of the top software companies of the world.','http://www.microsoft.com/'),
	array('sony','A global multibillion electronics and entertainment company ','http://www.sony.com/'),
	array('dell','One of the biggest computer developers and assemblers.','http://www.dell.com/'),
	array('ebay','The biggest online auction and shopping websites.','http://www.ebay.com/'),
	array('digg','One of the most popular web 2.0 social networks.','http://www.digg.com/'),
	array('google','The company that redefined web search.','http://www.google.com/'),
	array('ea','The biggest computer game manufacturer.','http://www.ea.com/'),
	array('mysql','The most popular open source database engine.','http://www.mysql.com/'),
	array('hp','One of the biggest computer manufacturers.','http://www.hp.com/'),
	array('yahoo','The most popular network of social media portals and services.','http://www.yahoo.com/'),
	array('cisco','The biggest networking and communications technology manufacturer.','http://www.cisco.com/'),
	array('vimeo','A popular video-centric social networking site.','http://www.vimeo.com/'),
	array('canon','Imaging and optical technology manufacturer.','http://www.canon.com/')
);


// Randomizing the order of sponsors:

shuffle($sponsors);

			
			// Looping through the array:
			
			foreach($sponsors as $company)
			{
				echo'
				<div class="sponsor" title="Click to flip">
					<div class="sponsorFlip">
						<img src="img/sponsors/'.$company[0].'.png" alt="More about '.$company[0].'" />
					</div>
					
					<div class="sponsorData">
						<div class="sponsorDescription">
							'.$company[1].'
						</div>
						<div class="sponsorURL">
							<a href="'.$company[2].'">'.$company[2].'</a>
						</div>
					</div>
				</div>
				
				';
			}
		
		?>
Can anybody help me?

pd: I will pay if you want money
Reply With Quote
  #2  
Old 09-18-2012, 09:02 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try changing the word "echo" to "$output .= ", so that the line looks like this:

Code:
$output .= '

Edit: you may also have to remove the <?php and ?> from the beginning and end - I can't remember if they're allowed or not.
Reply With Quote
  #3  
Old 09-18-2012, 09:11 PM
cloferba cloferba is offline
 
Join Date: Apr 2009
Posts: 437
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can?t get this work
Reply With Quote
  #4  
Old 09-18-2012, 09:38 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, what happened? Did you try my suggestion, and if so, did you get any errors?
Reply With Quote
  #5  
Old 09-18-2012, 09:52 PM
cloferba cloferba is offline
 
Join Date: Apr 2009
Posts: 437
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I?m using borbole?s mod (http://www.forumservices.eu/vb/threa...ustom-Pages-15) and I receive an error) and I?m inserting php inside html code

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sponsor Flip Wall With jQuery &amp; CSS | Tutorialzine demo</title>
 
<link rel="stylesheet" type="text/css" href="styles.css" />
 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="jquery.flip.min.js"></script>
 
<script type="text/javascript" src="script.js"></script>
 
</head>
 
<body>
 
<h1>PET&PET PARTNERS</h1>
<h2><a href="http://www.petandpet.com">Go Back to Pet&Pet &raquo;</a></h2>
 
<?php
 
// Each sponsor is an element of the $sponsors array:
 
$sponsors = array(
    array('facebook','The biggest social network in the world.','http://www.facebook.com/'),
    array('adobe','The leading software developer targeted at web designers and developers.','http://www.adobe.com/'),
    array('microsoft','One of the top software companies of the world.','http://www.microsoft.com/'),
    array('sony','A global multibillion electronics and entertainment company ','http://www.sony.com/'),
    array('dell','One of the biggest computer developers and assemblers.','http://www.dell.com/'),
    array('ebay','The biggest online auction and shopping websites.','http://www.ebay.com/'),
    array('digg','One of the most popular web 2.0 social networks.','http://www.digg.com/'),
    array('google','The company that redefined web search.','http://www.google.com/'),
    array('ea','The biggest computer game manufacturer.','http://www.ea.com/'),
    array('mysql','The most popular open source database engine.','http://www.mysql.com/'),
    array('hp','One of the biggest computer manufacturers.','http://www.hp.com/'),
    array('yahoo','The most popular network of social media portals and services.','http://www.yahoo.com/'),
    array('cisco','The biggest networking and communications technology manufacturer.','http://www.cisco.com/'),
    array('vimeo','A popular video-centric social networking site.','http://www.vimeo.com/'),
    array('canon','Imaging and optical technology manufacturer.','http://www.canon.com/')
);
 
 
// Randomizing the order of sponsors:
 
shuffle($sponsors);
 
?>
 
 
 
<div id="main">
 
    <div class="sponsorListHolder">
 
     
        <?php
         
            // Looping through the array:
         
            foreach($sponsors as $company)
            {
                echo'
                <div class="sponsor" title="Click to flip">
                    <div class="sponsorFlip">
                        <img src="img/sponsors/'.$company[0].'.png" alt="More about '.$company[0].'" />
                    </div>
                 
                    <div class="sponsorData">
                        <div class="sponsorDescription">
                            '.$company[1].'
                        </div>
                        <div class="sponsorURL">
                            <a href="'.$company[2].'">'.$company[2].'</a>
                        </div>
                    </div>
                </div>
             
                ';
            }
     
        ?>
 
     
     
        <div class="clear"></div>
    </div>
 
</div>
 
<p class="note">We thank to all of them :)</p>
 
</body>
</html>
I?ve deleted the <?php and ?> and also changed "echo" to "$output .= '" and I can?t see the code, it seems that something is wrong
Reply With Quote
  #6  
Old 09-18-2012, 10:00 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't understand what that mod has to do with this, I thought you were trying to create a php type forum block. In that case you'd be entering that code (from the first post) in the Forum Block manager when you create a new "Custom HTML/PHP" block. But one thing I forgot is that using $output is for widgets. For forum blocks you need to return the value, so you'd also have to add

Code:
return $output;

as the last line.
Reply With Quote
  #7  
Old 09-18-2012, 10:08 PM
ForumsMods ForumsMods is offline
 
Join Date: Aug 2007
Location: Argentina
Posts: 667
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If I understand, you want this:
PHP Code:
foreach($sponsors as $company)
{
    
$output '
    <div class="sponsor" title="Click to flip">
        <div class="sponsorFlip">
            <img src="img/sponsors/'
.$company[0].'.png" alt="More about '.$company[0].'" />
        </div>
     
        <div class="sponsorData">
            <div class="sponsorDescription">
                '
.$company[1].'
            </div>
            <div class="sponsorURL">
                <a href="'
.$company[2].'">'.$company[2].'</a>
            </div>
        </div>
    </div>
    '
;
}

echo 
$output
Reply With Quote
  #8  
Old 09-18-2012, 10:13 PM
cloferba cloferba is offline
 
Join Date: Apr 2009
Posts: 437
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I will make things clear, sorry guys.

From the beginning I said that was for a forumblock to don?t give more details about the situations (it seems complex but it is not)

Actually, I want implement a sponsor wall on my forum, using a custom page created with Borbole?s mod:
http://tutorialzine.com/2010/03/spon...ip-jquery-css/

What I need to do is adapt the code of the index.php file (http://demo.tutorialzine.com/2010/03...y-css/demo.php) to work on vBulletin...

That php file has html inside, but to work with php on vbulletin you need to use $output variables and that?s my main problem, I don?t know how can I adapt this code.
Reply With Quote
  #9  
Old 09-19-2012, 06:40 PM
Scanu's Avatar
Scanu Scanu is offline
 
Join Date: Nov 2010
Posts: 829
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Should'nt be "return $output"?
PHP Code:
foreach($sponsors+as+$company)
{
++++
$output+=+'
++++<div+class="sponsor"+title="Click+to+flip">
++++++++<div+class="sponsorFlip">
++++++++++++<img+src="img/sponsors/'
.$company[0].'.png"+alt="More+about+'.$company[0].'"+/>
++++++++</div>
+++++
++++++++<div+class="sponsorData">
++++++++++++<div+class="sponsorDescription">
++++++++++++++++'
.$company[1].'
++++++++++++</div>
++++++++++++<div+class="sponsorURL">
++++++++++++++++<a+href="'
.$company[2].'">'.$company[2].'</a>
++++++++++++</div>
++++++++</div>
++++</div>
++++'
;
}

return+
$output;+ 
--------------- Added [DATE]1348083681[/DATE] at [TIME]1348083681[/TIME] ---------------

Sorry for ++, i copied text from my iPad and it looked like that
Reply With Quote
  #10  
Old 10-05-2012, 05:50 AM
Crotan's Avatar
Crotan Crotan is offline
 
Join Date: Feb 2010
Posts: 249
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't mean to threadcrap, but is there a consensus on this?

I have php code that works fine, and the only way I've found to use it in a cms widget is using an html iframe to the php file because I'm not really sure what needs to change for it to be usable in a php widget?
Reply With Quote
Reply


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 09:41 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.06352 seconds
  • Memory Usage 2,276KB
  • Queries Executed 11 (?)
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
  • (4)bbcode_code
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete