Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

DataObjectManager : <% sprintf(....) %> displayed on the website


Go to End


48 Posts   13711 Views

Avatar
Vegas Rob

Community Member, 5 Posts

30 April 2010 at 10:32am

Just to add my data to the mix in case it is helpful. I also had this issue while developing locally using xamp 1.7.3, but I also had the same issues trying to use WAMP Server 2.0i (tried apache 2.2.11 default and 2.2.4).

However it all magically works when I upload the same code to my demo OSX server. I'll report back in the production Linux box also works later.

Very strange issue. I wouldn't really know where to start debugging this. Developing this part on the server for now.

Avatar
cake

Community Member, 19 Posts

18 August 2010 at 1:46am

Are there any news on this? I've got the same issue with XAMPP 1.7.3 and DOM. Any workarounds to get it solved?

Avatar
UncleCheese

Forum Moderator, 4102 Posts

18 August 2010 at 3:52am

No, I still don't get it. If we can pin it down to a DOM specific issue, I'm happy to trouble shoot it, but I've tried moving that tag to the front end and I still get that output. It seems like it might be an SSViewer issue?

Avatar
Terry Apodaca

Community Member, 112 Posts

18 August 2010 at 4:01am

I honestly believe this isn't your DOM issue. I ONLY see this on my Windows machine with XAMPP installed. Nothing like this happens on my Mac, not on either of my linux machines.

Avatar
Chiasmata

Community Member, 5 Posts

4 October 2010 at 11:53pm

Hi

I'm having issues with this also .... ie. <% sprintf(....) %> being displayed in various places on local xampp windows setup.
Has anyone solved it all? Even if it's just a temporary workaround.
Apologies if I missed any other posts about it - couldn't see any answers elsewhere on the forum.

Cheers

Avatar
Chiasmata

Community Member, 5 Posts

5 October 2010 at 4:11am

OK, after a few hours I think I finally solved it.

Thanks to the previous post from MateuszU which pointed me in the right direction.
I changed the sapphire/core/SSViewer.php file from:

      // i18n sprintf(_t(...),$argument) with entity only (no dots in namespace), meaning the current template filename will be added as a namespace
      $content = ereg_replace('<' . '% +sprintf\(_t\((\'([^\.\']*)\'|"([^\."]*)")(([^)]|\)[^ ]|\) +[^% ])*)\),\<\?= +([^\?]*) +\?\>) +%' . '>', '<?= sprintf(_t(\''. $path[1] . '.\\2\\3\'\\4),\\6) ?>', $content);
      // i18n sprintf(_t(...),$argument)
      $content = ereg_replace('<' . '% +sprintf\(_t\((\'([^\']*)\'|"([^"]*)")(([^)]|\)[^ ]|\) +[^% ])*)\),\<\?= +([^\?]*) +\?\>) +%' . '>', '<?= sprintf(_t(\'\\2\\3\'\\4),\\6) ?>', $content);

to...

// i18n sprintf(_t(...),$argument) with entity only (no dots in namespace), meaning the current template filename will be added as a namespace
		$content = preg_replace('/<' . '% +sprintf\(_t\((\'([^\.\']*)\'|"([^\."]*)")(([^)]|\)[^ ]|\) +[^% ])*)\),\<\?= +([^\?]*) +\?\>\) +%' . '>/', '<?= sprintf(_t(\''. $path[1] . '.\\2\\3\'\\4),\\6) ?>', $content); 
		// i18n sprintf(_t(...),$argument)
		$content = preg_replace('/<' . '% +sprintf\(_t\((\'([^\']*)\'|"([^"]*)")(([^)]|\)[^ ]|\) +[^% ])*)\),\<\?= +([^\?]*) +\?\>\) +%' . '>/', '<?= sprintf(_t(\'\\2\\3\'\\4),\\6) ?>', $content); 

Basically, it looks like there's a problem with the now deprecated ereg_replace function so I just changed it to a preg_replace function instead.
I'm kind of new to Silverstripe, so not sure yet how to go about getting this included in future releases (if it fully works of course). Perhaps someone can point me in the right direction or add it themselves?
Hopefully these deprecated ereg functions will be replaced everywhere eventually.

Avatar
kb

Community Member, 4 Posts

7 October 2010 at 8:31am

Chiasmata: I can confirm that your solution works perfectly with XAMPP 1.7.3!

Thank you very much.

Avatar
DsX

Community Member, 178 Posts

15 October 2010 at 2:59am

thanks, thats working for me...
since it only gave me trouble on my local xampp install, i put it in a condition so the 'official' code runs on the live server... just in-case ;)

good work! That looks like it would have been a trick to track down.