peterb Posted April 13, 2012 Share Posted April 13, 2012 I am in the process of upgrading a processwire site from 2.0 to 2.2, and have found that where I was once able to bootstrap, I am no longer. I am calling processwire from a wordpress install, and this used to work in 2.0 include("./pw/index.php"); // bootstrap ProcessWire $client = $wire->pages->find("template=client, client_email=$email")->first(); now in 2.2 this fails, and I get error like this: [error] PHP Fatal error: Cannot redeclare __() (previously declared in /var/www/vhosts/dev.sitename.com/httpdocs/wp-includes/l10n.php:96) in /var/www/vhosts/sitename.mysite.com/httpdocs/pw/wire/core/LanguageFunctions.php on line 38, referer: http://dev.sitename.com/markets-served/overview/ which seems to colide with a wordpress function: function __( $text, $domain = 'default' ) { return translate( $text, $domain ); } Not really versed enough to go much farther than this... does anyone know a remedy? thanks, Peter Link to comment Share on other sites More sharing options...
diogo Posted April 13, 2012 Share Posted April 13, 2012 should be the same function so, for now, this would solve: choose one of those files, find the function and wrap it in this conditional if ( !function_exists('__') ) : // the function endif; edit: or maybe you can just include_once, instead of include... i don't know if it would have any side effects. Link to comment Share on other sites More sharing options...
peterb Posted April 13, 2012 Author Share Posted April 13, 2012 thankyou Diogo, There were 3 functions in LanguageFunctions.php that were the culpret... by wrapping them as you suggested made everthing work again.. thanks. Link to comment Share on other sites More sharing options...
ryan Posted April 13, 2012 Share Posted April 13, 2012 The only problem there is that PW's output is then getting routed through WordPress's language functions and gettext(). If it works, great, but definitely potential for unknowns and extra overhead. One alternate approach would be to avoid including PW from WordPress and instead have WordPress load PW's output from a web service. For instance, you could do this in your WordPress template file: echo file_get_contents("http://domain.com/path/to/page/"); If you need to pass any params to do, just use GET vars: echo file_get_contents("http://domain.com/path/to/page/?var1=abc&var2=123"); Your PW page template will render the content for inclusion in your WordPress page, meaning a block of HTML (partial) rather than a full HTML document. Link to comment Share on other sites More sharing options...
Giles Posted June 5, 2012 Share Posted June 5, 2012 Ryan, do you have any plans to resolve this kind of issue by namespacing your functions or similar? We have a similar issue and will probably "shell out" to a PW block for the integration as you suggested, but it definitely makes things more tricky. Link to comment Share on other sites More sharing options...
ryan Posted June 6, 2012 Share Posted June 6, 2012 Once PHP 5.4 is pretty mainstream (later this year?) we'll drop support for PHP 5.2 and then use PHP 5.3 namespaces. But lots of folks are still running on PHP 5.2 (including me on a few servers) and I don't see any way to be backwards compatible with PHP 5.2 once we start using namespaces. Still, I'm anxious to get them in the PW core and just trying to find the right time when it'll help more people than it will hurt. Link to comment Share on other sites More sharing options...
Giles Posted June 7, 2012 Share Posted June 7, 2012 FYI anyone else looking to implement Ryan's solution for authenticated ProcessWire pages: you can make the request via cURL and pass the cookies in along these lines: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://$_SERVER[HTTP_HOST]/path/to/content"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_COOKIE, $_SERVER['HTTP_COOKIE']); $content = curl_exec($ch); BIG CAVEAT: set $config->sessionFingerprinting to FALSE, or the code above will log your users out. 2 Link to comment Share on other sites More sharing options...
guy Posted April 5, 2013 Share Posted April 5, 2013 We're currently putting together a client portal and are wondering if it's possible to request an authenicated Processwire page from another Processwire site on a subdomain? (subdomain structure follows method 1: http://processwire.com/api/modules/multi-site-support/ i.e seperate databases) The client portal sits on portal.domain.com & the client Processwire sites will sit at client1.domain.com. We're wanting a solution where connections to client1.domain.com are blocked unless the user has authenicated on portal.domain.com. The reason for not simple authenticating the client on client1.domain.com is we are creating a dashboard for the projects which requires authentication to access at portal.domain.com. This will allow each client to list their projects, view them (i.e why we need this to work), approve stages, store docs etc. Any advice or pointers would be awesome, Link to comment Share on other sites More sharing options...
ryan Posted April 7, 2013 Share Posted April 7, 2013 How much do you need to know about the portal.domain.com authenticated user on client1.domain.com? Do you just need to know that they are logged in, or do you need to connect them with another account on client1.domain.com? I'm just trying to better understand the extend of access control needs at client1 and whether this is a simple authenticated "yes or no", or broader in scope. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now