Jump to content
snobjorn

Problem with multi-instance giving array notice

Recommended Posts

I'm trying the recently added multi-instance support in a local environment, and has encountered some problems. There's not much code, so I'll paste all I have and some info on the installations (both are ProcessWire 3.0.33), and pinpoint the issues as I go:
 

In a template on www.testdomain.pw (local through MAMP)

<?php
// Server path to the PW installation
$path = "/Users/name/documents/testdomain/studiehandbok/";

// The root URL for the PW installation
$url = "/studiehandbok/";

// Create a new ProcessWire instance
$mi_studiehandbok = new ProcessWire($path, $url);

// get study pages
$subjects = $mi_studiehandbok->pages->find("template=study, limit=2");

// output list
foreach ($subjects as $sub) {
echo "<a href='$sub->httpUrl'>$sub->title</a><br>";
}
?>

Issues: The echo will show the correct Url. But as for title, only a list of the text Array will show. But echoing name instead of title works.
Comment: as for $url, when I had http://www.testdomain.pw/studiehandbok/ as the root URL for the PW installation, the first slash "/" after www.testdomain.pw disappeared.

In config-dev.php on the /studiehandbok/ multi-instance installation

$config->httpHosts = array('www.testdomain.pw');

Comment: This multi-installation is located in a subfolder of my main PW installation. The subfolder is as shown in $path above, called /studiehandbok/

PS:
I've also tried with another local installation as the multi-instance, also giving an error on the line of the ->title Notice: Array to string conversion in my template.

PS2:
I tried to find template=home and others. With home the title actually showed, but only then (tested a few).

I'll provide more details if necessary, but I didn't know exactly what to include.

Share this post


Link to post
Share on other sites

I'm having the same issue, it seems to only affect fields with language support. Which makes the ->title property an array containing ['data'], I'm trying other fields with language support, like a textarea, and they give the same error but are inaccessible through the ['data'] array key.

I guess multiple languages are not yet supported on multi-instance.

Share this post


Link to post
Share on other sites

You guys are mentioning an array rather than an object is being returned, so I am probably not correct here, but might be worth a shot - I wonder if outputformatting is off when calling a field from another instance? Try turning it on for the page, or using:  $page->getFormatted('title');

Again, I a, probably wrong, but I haven't played with multi-instance yet so just throwing an idea out there.

Share this post


Link to post
Share on other sites

With $page->getFormatted('title') I get this error:

Notice: Array to string conversion in wire/modules/LanguageSupport/FieldtypeTextLanguage.module on line 69

 

Share this post


Link to post
Share on other sites
Just now, yuters said:

With $page->getFormatted('title') I get this error:

Notice: Array to string conversion in wire/modules/LanguageSupport/FieldtypeTextLanguage.module on line 69

 

Yeah, that would make sense since it's an array. 

Will have to wait for someone who has some experience with multi-instance to chime in.

Share this post


Link to post
Share on other sites

I can't test it right now, but one thought is that maybe user language might not get initialized correctly for the instance. Does setting the language explicitly before retrieving the subjects help?

$mi_studiehandbok->user->language = $mi_studiehandbok->languages->get('default');

 

Share this post


Link to post
Share on other sites

No luck with your language suggestion, BitPoet.

At least not like this on my main site:

switch($user->language->name) {
    case 'default':
        setlocale (LC_ALL, $homepage->locale);
        break;
}

$mi_studiehandbok = new ProcessWire('/Users/asbjornness/documents/vid/studiehandbok', '/studiehandbok/');
$mi_studiehandbok->user->language = $mi_studiehandbok->languages->get('default');

And also repeating the switch-part on my secondary (multi-instanced) site. Both nb_NO to be precise in my case.

Still getting a list of the text Array with this code:

$subjects = $mi_studiehandbok->pages->find("template=subject, limit=10");

foreach ($subjects as $s) {
	echo "$s->title<br>";
}

 

Share this post


Link to post
Share on other sites

I am also having the same issue with 3.0.36 - it only seems to affect multilanguage fields like TextLanguage, PageTitleLanguage and TextareaLanguage. Has anyone found a work around or should I add this to the issues repository?  

Share this post


Link to post
Share on other sites

To update those on this thread, Ryan just pushed some fixes to the dev branch which fixed this issue for me, maybe also for you.

Amazing turnaround - less than 5 days (3 actual working days) from a bug submission to a working fix. Big up respect to @ryan

Would be interesting to hear what people are planning to use the multi-instance support for. My initial needs are for some content migration between two sites, but I can imagine using it for much more in the future.

 

  • Like 2

Share this post


Link to post
Share on other sites
On 31.10.2016 at 7:40 PM, Michael Murphy said:

To update those on this thread, Ryan just pushed some fixes to the dev branch which fixed this issue for me, maybe also for you.

Nice. I'll check it out tomorrow!

Edit: I can confirm that the fix is working. I've been able to set up multi instance with multiple language without problems.

On 31.10.2016 at 7:40 PM, Michael Murphy said:

Would be interesting to hear what people are planning to use the multi-instance support for. My initial needs are for some content migration between two sites, but I can imagine using it for much more in the future.

I'm a web editor at a university college's web page. And we'll be using this to integrate parts of a study guide (academic presentation of study programs and its subjects) into our main web page where our primary focus is marketing of these programs.

  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...