vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB5 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=263)
-   -   Custom Header Extension :: Not showing for guests (https://vborg.vbsupport.ru/showthread.php?t=317723)

AlexBrock 03-10-2015 08:18 PM

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.

Lynne 03-11-2015 01:26 AM

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.

AlexBrock 03-12-2015 03:20 PM

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

        }       

}


AlexBrock 03-18-2015 11:50 PM

Sorry to bug, Lynne. Do you have any idea what could be happening with this?

Lynne 03-20-2015 03:56 PM

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.

AlexBrock 03-20-2015 05:37 PM

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.


All times are GMT. The time now is 09:11 PM.

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.01052 seconds
  • Memory Usage 1,733KB
  • 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
  • (3)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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