Go Back   vb.org Archive > vBulletin 5 Connect Discussion > vB5 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-10-2015, 08:18 PM
AlexBrock AlexBrock is offline
 
Join Date: Mar 2015
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Custom Header Extension :: Not showing for guests

I've hit a stumbling block when it comes to using a custom API Extension for vB5, I'm hoping someone else may have experienced this and have a solution.

I've developed an API Extension which pulls in an external header to make our forum more inline with our main site. This is all working perfectly for my admin account, however if I log out the header is no longer visible. I've check the user permissions in the Usergroup Manager tab and nothing stands out as being a problem.

Any advice would be greatly appreciated.
Reply With Quote
  #2  
Old 03-11-2015, 01:26 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Perhaps post your code so we can see what you did. It's really impossible to tell what the problem is without know exactly what you did.
Reply With Quote
  #3  
Old 03-12-2015, 03:20 PM
AlexBrock AlexBrock is offline
 
Join Date: Mar 2015
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That would be helpful wouldn't it!

So in the template file I have:
Code:
{vb:data returnHead, options, mcheadfunction}
{vb:raw returnHead}
Which is calling my API:

Code:
<?php 
class Mcheadd_Api_Options extends vB_Api_Extensions
{
	public $product = 'mcheadd';

	public $developer = 'Developer';
	public $title = 'Pull in Domain Name header';
	public $minver = '5.1.0';
	// public $maxver = '5.9.99';// Use vB default.
	// public $infourl = 'Domain Name';
	// public $checkurl = 'Domain Name';

	public $AutoInstall = 0;
	public $extensionOrder = 10;

	public function mcheadfunction(){
		// create curl resource 
        $ch = curl_init(); 

        // set url 
        curl_setopt($ch, CURLOPT_URL, "DomainName"); 

        //return the transfer as a string 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

        // $output contains the output string 
        $output = curl_exec($ch); 

        $page_parts = explode('<!-- Top navigtation -->', $output);
        $page_parts = explode('<!-- DAB container -->', $page_parts[1]);

 $header_html = '<div id="header-mc">' . $page_parts[0] ;

        $header_html = str_replace("'", '"', $header_html);

        $output = str_replace(array("\r\n", "\r"), "\n", $header_html);
		$lines = explode("\n", $output);
		$new_lines = array();

		foreach ($lines as $i => $line) {
		    if(!empty($line))
		        $new_lines[] = trim($line);
		}
		$pageStuff = implode($new_lines);

		echo '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>';

        echo "<script> $(document).ready(function(){  $('#outer-wrapper').prepend('" . $pageStuff . "'); $('.hamburger').click(function(){ $('#nav_top ul').toggleClass('mobile_show'); });}); </script>";

        curl_close($ch); 

	}	

}
Reply With Quote
  #4  
Old 03-18-2015, 11:50 PM
AlexBrock AlexBrock is offline
 
Join Date: Mar 2015
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry to bug, Lynne. Do you have any idea what could be happening with this?
Reply With Quote
  #5  
Old 03-20-2015, 03:56 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I really have not spent much time doing coding for vB5 which is why I didn't answer. I do wonder why do you have both these lines when the second one will replace the first one?
Code:
        $page_parts = explode('<!-- Top navigtation -->', $output);
        $page_parts = explode('<!-- DAB container -->', $page_parts[1]);
Also, echos aren't a good idea (unless it is debug code). I am pretty sure you want to do a return with the html and then spit it out into a template.

Other than that, there really isn't enough information for us to be able to 'install' it on our own test site and see what is going on.
Reply With Quote
  #6  
Old 03-20-2015, 05:37 PM
AlexBrock AlexBrock is offline
 
Join Date: Mar 2015
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the reply.

I have both of those lines so that I'm only using the code in between those two comments to avoid unnecessary markup.

I've tried even doing a simple return of a string, which also doesn't appear when the user isn't logged in but is there if logged in.

PHP Code:
<?php 
class Mcheadd_Api_Options extends vB_Api_Extensions
{
    public 
$product 'mcheadd';

    public 
$developer '';
    public 
$title 'Pull in Site header';
    public 
$minver '5.1.0';
    
// public $maxver = '5.9.99';// Use vB default.
    // public $infourl = '';
    // public $checkurl = '';

    
public $AutoInstall 0;
    public 
$extensionOrder 10;

    public function 
mcheadfunction(){
        return 
'Test String';
    }    

}
these are stored in core/packages/mcheadd/api if that's any help

--------------- Added [DATE]1426877795[/DATE] at [TIME]1426877795[/TIME] ---------------

Lynne!

Changing the echo to return worked, not sure why but it did!

Thanks for all your help, you're my hero.
Reply With Quote
Благодарность от:
Lynne
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 04:43 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.04000 seconds
  • Memory Usage 2,218KB
  • 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
  • (3)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (1)post_thanks_box_bit
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete