Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 07-05-2010, 03:10 PM
Xencored Xencored is offline
 
Join Date: Sep 2008
Location: UK, Scuny
Posts: 1,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Is this posable

I have a none vbulletin page

and i wish to take a small of bit of it and add it as a widget and block for the side bar

is this posable?

PHP Code:
<?php
/*
* Name: Home Page
* Author: Bzchan <bzchan@animemahou.com>
* License: GPLv2
* Visibility: admin
* Description: Displays a front page with logo, search box and image count
* Documentation:
*  Once enabled, the page will show up at the URL "home", so if you want
*  this to be the front page of your site, you should go to "Board Config"
*  and set "Front Page" to "home".
*  <p>The images used for the numbers can be changed from the board config
*  page. If you want to use your own numbers, upload them into a new folder
*  in <code>/ext/home/counters</code>, and they'll become available
*  alongside the default choices.
*/

class Home extends SimpleExtension {
    public function 
onInitExt(InitExtEvent $event) {
        global 
$config;
        
$config->set_default_string("home_links"'[$base/post/list|Posts]
[$base/comment/list|Comments]
[$base/tags|Tags]
[$base/wiki|Wiki]
[$base/wiki/more|&raquo;]'
);
    }

    public function 
onPageRequest(PageRequestEvent $event) {
        global 
$config$page;
        if(
$event->page_matches("home")) {
            
$base_href $config->get_string('base_href');
            
$data_href get_base_href();
            
$sitename $config->get_string('title');
            
$theme_name $config->get_string('theme');

            
$body $this->get_body();

            
$this->theme->display_page($page$sitename$data_href$theme_name$body);
        }
    }

    public function 
onSetupBuilding(SetupBuildingEvent $event) {
        
$counters = array();
        foreach(
glob("ext/home/counters/*") as $counter_dirname) {
            
$name str_replace("ext/home/counters/"""$counter_dirname);
            
$counters[ucfirst($name)] = $name;
        }

        
$sb = new SetupBlock("Home Page");
        
$sb->add_longtext_option("home_links"'Page Links - Example: [/post/list|Posts]<br>');
        
$sb->add_longtext_option("home_text""<br>Page Text:<br>");
        
$sb->add_choice_option("home_counter"$counters"<br>Counter: ");
        
$event->panel->add_block($sb);
    }


    private function 
get_body() {
        
// returns just the contents of the body
        
global $database;
        global 
$config;
        
$base_href $config->get_string('base_href');
        
$data_href get_base_href();
        
$sitename $config->get_string('title');
        
$contact_link $config->get_string('contact_link');
        
$counter_dir $config->get_string('home_counter''default');

        
$total Image::count_images();
        
$strtotal "$total";
        
$num_comma number_format($total);

        
$counter_text "";
        for(
$n=0$n<strlen($strtotal); $n++) {
            
$cur $strtotal[$n];
            
$counter_text .= " <img alt='$cur' src='$data_href/ext/home/counters/$counter_dir/$cur.gif' />  ";
        }

        
// get the homelinks and process them
        
$main_links $config->get_string('home_links');
        
$main_links str_replace('$base',    $base_href,     $main_links);
        
$main_links preg_replace('#\[(.*?)\|(.*?)\]#'"<a href='\\1'>\\2</a>"$main_links);
        
$main_links str_replace('//',    "/"$main_links);

        
$main_text $config->get_string('home_text');

        return 
$this->theme->build_body($sitename$main_links$main_text$contact_link$num_comma$counter_text);
    }
}
?>
That is the page but all i want is the counters



Thanks :up:
Reply With Quote
  #2  
Old 07-05-2010, 08:10 PM
eSekar's Avatar
eSekar eSekar is offline
 
Join Date: Jun 2010
Posts: 94
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PM me a Live link for that page in a working condition, I'll try to find it, If I can't then I'll ask you for more information.
Reply With Quote
  #3  
Old 07-05-2010, 08:27 PM
Xencored Xencored is offline
 
Join Date: Sep 2008
Location: UK, Scuny
Posts: 1,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<a href="http://www.myanimeisland.com/imageboard/home" target="_blank">http://www.myanimeisland.com/imageboard/home</a>

But its closed sadly :/
Reply With Quote
  #4  
Old 07-05-2010, 08:37 PM
eSekar's Avatar
eSekar eSekar is offline
 
Join Date: Jun 2010
Posts: 94
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, bed time for me anyway lool

I'll take a look at it tomorrow first thing.

P.S: nice avatar :P
Reply With Quote
  #5  
Old 07-05-2010, 08:39 PM
Xencored Xencored is offline
 
Join Date: Sep 2008
Location: UK, Scuny
Posts: 1,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks

and aye i seem to change it alot :S
Reply With Quote
  #6  
Old 07-07-2010, 02:48 PM
Xencored Xencored is offline
 
Join Date: Sep 2008
Location: UK, Scuny
Posts: 1,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Bumb can anyone help me with info on this please
Reply With Quote
  #7  
Old 07-08-2010, 02:29 AM
Darkwaltz4's Avatar
Darkwaltz4 Darkwaltz4 is offline
 
Join Date: Oct 2002
Location: Chicago
Posts: 1,538
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

try this

PHP Code:
<?php
$output 
'';
$cdb = new PDO('mysql:dbname=testdb;host=localhost''dbuser''dbpass');
$res $cdb->query("SELECT COUNT(*) AS imgtotal FROM images");
$ct $res->fetch(PDO::FETCH_ASSOC);
for (
$x 0$x strlen($ct['imgtotal']); $x++) $output .= ' <img alt="' $ct['imgtotal'][$x] . '" src="/ext/home/counters/default/' $ct['imgtotal'][$x] . '.gif" />';
echo 
$output;
?>
Reply With Quote
  #8  
Old 07-08-2010, 02:43 AM
Xencored Xencored is offline
 
Join Date: Sep 2008
Location: UK, Scuny
Posts: 1,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Darkwaltz4 View Post
try this

PHP Code:
<?php
$output 
'';
$cdb = new PDO('mysql:dbname=testdb;host=localhost''dbuser''dbpass');
$res $cdb->query("SELECT COUNT(*) AS imgtotal FROM images");
$ct $res->fetch(PDO::FETCH_ASSOC);
for (
$x 0$x strlen($ct['imgtotal']); $x++) $output .= ' <img alt="' $ct['imgtotal'][$x] . '" src="/ext/home/counters/default/' $ct['imgtotal'][$x] . '.gif" />';
echo 
$output;
?>
Omg i could kiss you dark thank you soo dam much!!
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 05:42 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.09296 seconds
  • Memory Usage 2,275KB
  • Queries Executed 13 (?)
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
  • (3)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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_postinfo_query
  • fetch_postinfo
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete