Implemented Provide the ability to call a php file directly from template

AndyB

Well-known member
It would be awesome to be able to call a php file directly from a template without the need for an Addon and hook. For example:

<xen: include "/path/script.php">
 
Upvote 0
This suggestion has been implemented. Votes are no longer accepted.
:ROFLMAO: The force of sleep is overwhelming. :sleep:

Thanks for answering. I wasn't sure if it started at /library or /community or / ...

It's ALWAYS library (except you're using your own autoloaders to inject composer support, but that's coming in the courses next year^^)
 
Let me clarify ... would it be possible to use this to call an external page (outside XF)?

Let's say files are

/community
/blog

Could files from /blog be called?

Update:

This is my thought ...

template calls a php file located in /library/Tux/Footer with the class = Tux_Footer ...

In that file is a

PHP:
define('__ROOT__', dirname(dirname(__FILE__))); 
require_once(__ROOT__.'/config.php');

Or something along that line ...
 
Let me clarify ... would it be possible to use this to call an external page (outside XF)?

Let's say files are

/community
/blog

Could files from /blog be called?

Update:

This is my thought ...

template calls a php file located in /library/Tux/Footer with the class = Tux_Footer ...

In that file is a

PHP:
define('__ROOT__', dirname(dirname(__FILE__)));
require_once(__ROOT__.'/config.php');

Or something along that line ...
Try it out:P (that's the best & fastest way instead of waiting for a reply:D )

may-the-force-be-with-you.jpg
 
I imagine this wouldn't work as /library/ is the base directory for <xen:callback> callbacks. It'd require editing code.
 
Try it out:p (that's the best & fastest way instead of waiting for a reply:D )

Now that I'm near my test environment ... ;)

Created /library/Tux/Widget.php
Added callback to template
Tried different paths ...

require or require_once give these errors:

Code:
[B]Fatal error[/B]: require() [[URL='http://localhost/community/function.require']function.require[/URL]]: Failed opening required 'http://localhost/wp-blog-header.php' (include_path='C:\Program Files (x86)\Zend\Apache2\htdocs\community/library;.;.;C:\Program Files (x86)\Zend\ZendServer\share\ZendFramework\library') in [B]C:\Program Files (x86)\Zend\Apache2\htdocs\community\library\Tux\Widget.php[/B] on line [B]6[/B]

include or include_once gives these errors:

Code:
[SIZE=3][B]Template Errors: PAGE_CONTAINER[/B][/SIZE]
[LIST=1]
[*][I]include_once() [<a href='function.include-once'>function.include-once</a>]: [URL]http:// wrapper[/URL] is disabled in the server configuration by allow_url_include=0[/I] in C:\Program Files (x86)\Zend\Apache2\htdocs\community\library\Tux\Widget.php, line 6:
5: ';
6: $__compilerVar1 = '';
7: $__compilerVar1 .= '
[*][I]include_once([URL]http://localhost/wp-blog-header.php[/URL]) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: no suitable wrapper could be found[/I] in C:\Program Files (x86)\Zend\Apache2\htdocs\community\library\Tux\Widget.php, line 6:
5: ';
6: $__compilerVar1 = '';
7: $__compilerVar1 .= '
[*][I]include_once() [<a href='function.include'>function.include</a>]: Failed opening '[URL]http://localhost/wp-blog-header.php[/URL]' for inclusion (include_path='C:\Program Files (x86)\Zend\Apache2\htdocs\community/library;.;.;C:\Program Files (x86)\Zend\ZendServer\share\ZendFramework\library')[/I] in C:\Program Files (x86)\Zend\Apache2\htdocs\community\library\Tux\Widget.php, line 6:
5: ';
6: $__compilerVar1 = '';
7: $__compilerVar1 .= '
[/LIST]
 
This has helped me loads.. still messing around with this but will provide a tutorial for xf users once i get my head around it completely, so far ive noticed this is very powerful and has loads of potential.
 
How can I access xenForos Framework with xen:callback? I want to access models but $threadModel = XenForo_Controller::getModelFromCache('XenForo_Model_Thread'); does not work.
 
Hi, sorry to bump such an old thread.

I tried to include a php on my footer template.

Here's what I created in library/test/footer.php

Code:
<?php

class footinc {

  public static function getHtml(){
  include '/home/web/public_html/library/test/123.php';
  }
}

And then I used this on my footer template:

Code:
<xen:callback class="footinc" method="getHtml"></xen:callback>

But it doesn't work.

It returns me:
Code:
Could not execute callback footinc::getHtml() - Not callable.

What mistake could I've done here?

Any solution would be appreciated.

Thank you :)
 
This is the closed suggestions forum.

You should post support issues in the relevant customer forum.
 
Top Bottom