Virtual Happy Hour canceled for Friday May 31st.

Try our conversational search powered by Generative AI!

Broken images with a css flow from site A to site B

Vote:
 

I'am in for a major challange here.

The organisation I work for have a public site (lets call it site A), then we also have a site for tourism (site B). We have editors that write news for site A and publish them on the site. The editor then has an option (in edit mode for site A) to check a box named 'also publish on site B'. The news article then gets published on site B also. So far so good.

However all the images in the article get broken on site B. When I view the source code the path to the images are relative like this: /Global/_bilder/Nyheter/2011/theImage.jpg. Of course site B looks for that image in its own global files but cant find it. I would much more prefer the path like this: http://www.siteA.se/Global/_bilder/Nyheter/2011/theImage.jpg

The tech for all this, as I can fumble myself to, is an RSS flow from site A to site B. I have access to all the code for both site A and site B.

Is it possible to solve this in a simple way? Is it possible to solve in a more advanced way?

I'am a newbie developer - and thus struggeling to see an imediate solution, even though I have checked in several aspx and cs files for both sites. I can post code here if you want me to, just say so.

It would be totally fantastic if this could be solved. Thank you so so much. =)

#52672
Aug 09, 2011 11:04
Vote:
 

Import / Export should be able to handle this for you:

http://sdk.episerver.com/library/cms5/Developers%20Guide/Copy%20functionality.htm

Look in the SDK for the DataExporter and its property "Exclude files". Then it should copy the files to the other site as well.

#52683
Aug 09, 2011 17:13
Vote:
 

Or just set up a mirroring job, hook into the PageExporting event and only add the page if the checkbox property is set to true.

http://world.episerver.com/Modules/Forum/Pages/thread.aspx?id=49189

The simplest way would of course be to set up a mirroring channel and let the editors/administrators do the work for you ;) 

#52684
Aug 09, 2011 17:23
Vote:
 

Toni: Thank you for your reply, as always.

Regarding DataExporter. Hm, ok, so the idea is to somehow export the files (images), copy them, from one global files to another global files, and this should be done if the check box is checked. This is done by one export code with c# in a .cs file for Site A:s project. And one import code with c# in a .cs file for Site B:s project. And this works even though the sites are different projects?

Correct so far? If so, lets continue. In what .cs files? Export code in 'news.cs' in Site A:s project? Import code in what .cs file in Site B:s project (the .cs file to the apsx file where the news are displayed)?


Regarding Mirroring job. Hm, will that solution be in "conflict" with the rss flow that the prevoius developer did? I sort of just want to complement his code with this functionality so the images displayes properly as well. I would prefer if I didnt have to re code everything for this.

#52698
Aug 10, 2011 10:47
Vote:
 

Another idea from a friend (he looked at it very hastly). Here is a code snippet from a code behind file:

XmlNode itemBody = doc.CreateElement("mainbody");
itemBody.InnerText = page["Content"] as string;
// Here, some sort of search and replace
item.AppendChild(itemBody);

Where I have commented there should be some sort of search and replace. Any idea what to write?

#52703
Edited, Aug 10, 2011 11:46
Vote:
 

The source code (as I mention in my first post) says this on site B:
 /Global/_bilder/Nyheter/2011/theImage.jpg

I want to change this to:
http://www.siteA.se/Global/_bilder/Nyheter/2011/theImage.jpg

Would this work (in the comment place above)?
itemBody.InnerText.Replace("/global/","http://www.SiteA.se/global/");

#52709
Edited, Aug 10, 2011 13:31
Vote:
 

I did some tests on the rss template's (aspx file) .cs file on Site A. I then looked at the result on a page in Site A with the page type (rss template).

First I tried this, nothing happened to the img src.

XmlNode itemBody = doc.CreateElement("mainbody");
                itemBody.InnerText = page["Content"] as string;
                itemBody.InnerText.Replace("/global/", "http://www.siteA.se/global/");
                item.AppendChild(itemBody);

Then I tried this but got an compile error.

XmlNode itemBody = doc.CreateElement("mainbody");
                itemBody.InnerText = page["Content"] as string;
                string newstring = itemBody.InnerText.Replace("/global/", "http://www.siteA.se/global/");
                item.AppendChild(newstring);

2 errors:
# The best overloaded method match for 'System.Xml.XmlNode.AppendChild(System.Xml.XmlNode)' has some invalid arguments
# Argument '1': cannot convert from 'string' to 'System.Xml.XmlNode'

Any ideas? 

#52763
Aug 12, 2011 9:55
Vote:
 

This did the trick, from what I can tell from the source code. I have to test it live though, but pretty sure it works.

XmlNode itemBody = doc.CreateElement("mainbody");                
itemBody.InnerText = (page["Content"] as string).Replace("/Global/", "http://www.SiteA.se/Global/");
item.AppendChild(itemBody);

    

#52792
Aug 15, 2011 14:48
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.