External page in Content Page?
-
- Lieutenant (LT)
- Posts: 66
- Joined: Mon Jun 22, 2009 5:49 pm
External page in Content Page?
I need to display an external page as a Content Page. Can this be done?
Rick
Rick
Re: External page in Content Page?
We created a little ConLib control to read an external file, chop off the top and bottom, then display.
Here's the LoadAPage.ascx:
Here's the LoadAPage.ascx.cs:
You can adjust the beginBody and endBody search text. You might be okay just stripping after the <BODY> and before the </BODY>.
Hope this gets you on the right path.
Here's the LoadAPage.ascx:
Code: Select all
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="LoadAPage.ascx.cs" Inherits="ConLib_LoadAPage" EnableViewState="false" %>
<%--
<conlib>
<summary>Displays the contents of a web page..</summary>
<param name="WebURL" default="http://www.theexternalsite.com">Web page URL.</param>
</conlib>
--%>
<div class="section">
<div class="pageHeader">
<h1 class="heading"><asp:Localize ID="Caption" runat="server" Text="My Heading"></asp:Localize></h1>
</div>
<div id="hotDeals">
<asp:PlaceHolder ID="WebPageContents" runat="server"></asp:PlaceHolder>
</div>
</div>
Code: Select all
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Net;
using System.IO;
using CommerceBuilder.Common;
using CommerceBuilder.Orders;
public partial class ConLib_LoadAPage : System.Web.UI.UserControl
{
private string _WebURL = "http://www.theexternalsite.com/pagename.html";
[Personalizable(), WebBrowsable()]
public string WebURL
{
get { return _WebURL; }
set { _WebURL = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(WebURL);
myRequest.Method = "GET";
WebResponse myResponse = myRequest.GetResponse();
StreamReader sr = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8);
string result = sr.ReadToEnd();
sr.Close();
myResponse.Close();
int beginBody = result.IndexOf("<table width=\"834\"");
int endBody = result.Substring(beginBody).IndexOf("</table>") + "</table>".Length;
string asBody = result.Substring(beginBody, endBody);
WebPageContents.Controls.Add(new LiteralControl(asBody));
}
}
Hope this gets you on the right path.
-
- Lieutenant (LT)
- Posts: 66
- Joined: Mon Jun 22, 2009 5:49 pm
Re: External page in Content Page?
Thanks, however, I'm not sure how to use this with a content page.
Re: External page in Content Page?
You'll have to create a new ASPX page. I don't think the webpages can process ConLib controls.
Make a copy of the default.aspx page in the root directory and give it a new name that makes sense based on the content you're going to display. For the sake of discussion, let's say you called it LoadAPage.aspx.
In the admin, go to WEBSITE >> MANAGE SCRIPTLETS and create a new CONTENT type scriptlet. For the Content section, put in the ConLib control:
Login in as an admin, then browse to http://www.yoursite.com/LoadAPage.aspx and update the Content to your new CONTENT scriptlet. Save the page and providing you've updated the LoadAPage.ascx.cs to look for the correct page and filter text, you should see your remote content.
Here's an updated LoadAPage.aspx.cs that will display a subset of data from the AbleCommerce Software Support page:
You could make the LoadAPage ConLib more generic by also passing in the beginBody and endBody text. Then you could use one LoadAPage.aspx page to display content from many other sites.
The tricky part can be pulling the correct content from the remote site, especially if the remote site uses local javascript or local CSS files.
I hope this helps.
Make a copy of the default.aspx page in the root directory and give it a new name that makes sense based on the content you're going to display. For the sake of discussion, let's say you called it LoadAPage.aspx.
In the admin, go to WEBSITE >> MANAGE SCRIPTLETS and create a new CONTENT type scriptlet. For the Content section, put in the ConLib control:
Code: Select all
[[Conlib:Custom\LoadAPage]]
Here's an updated LoadAPage.aspx.cs that will display a subset of data from the AbleCommerce Software Support page:
Code: Select all
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Net;
using System.IO;
using CommerceBuilder.Common;
using CommerceBuilder.Orders;
public partial class ConLib_LoadAPage : System.Web.UI.UserControl
{
private string _WebURL = "http://www.ablecommerce.com/Software-Support-C112.aspx";
[Personalizable(), WebBrowsable()]
public string WebURL
{
get { return _WebURL; }
set { _WebURL = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(WebURL);
myRequest.Method = "GET";
WebResponse myResponse = myRequest.GetResponse();
StreamReader sr = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8);
string result = sr.ReadToEnd();
sr.Close();
myResponse.Close();
int beginBody = result.IndexOf("<div class=\"features\">");
int endBody = result.Substring(beginBody).IndexOf("</div>") + "</div>".Length;
string asBody = result.Substring(beginBody, endBody);
WebPageContents.Controls.Add(new LiteralControl(asBody));
}
}
The tricky part can be pulling the correct content from the remote site, especially if the remote site uses local javascript or local CSS files.
I hope this helps.
-
- Lieutenant (LT)
- Posts: 66
- Joined: Mon Jun 22, 2009 5:49 pm
Re: External page in Content Page?
Thanks Dave. Closer but still having trouble. I've followed your steps to the letter, substituting my information where appropriate. When I go to http:MySite.com/MyNewPage.aspx, I see the site start to show but then the screen is replaced with my external page; it's appearing as the whole page, not as content in the store.
Rick
Rick
-
- Lieutenant (LT)
- Posts: 66
- Joined: Mon Jun 22, 2009 5:49 pm
Re: External page in Content Page?
I have the content displayed now. However, it's having a problem with its form submission. The external content has its own form but clicking the submit button no longer works An examination of the html source suggests it is trying to submit AC's form. I do not even see the external form's beginning <form>.
Rick
Rick
Re: External page in Content Page?
Can you provide your code for the find begin and end code and the URL with the form?
If you don't see the external <form> tag then it could be outside your begin/end code. If the form tag is there, then you'll probably just need to do a search/replace on the ACTION attribute to include the URL of the host site.
Code: Select all
int beginBody = result.IndexOf("<div class=\"features\">");
int endBody = result.Substring(beginBody).IndexOf("</div>") + "</div>".Length;
-
- Lieutenant (LT)
- Posts: 66
- Joined: Mon Jun 22, 2009 5:49 pm
Re: External page in Content Page?
My begin line is:
int beginBody = result.IndexOf("<table");
The first reference of that is just after the body line and after that is the form line. So I don't think I'm chopping it off.
The url I'm reading is: http://www.promoplace.com/ws/ws.dll?DistID=4637
The end line is:
int endBody = result.Substring(beginBody).IndexOf("<iframe") ;
Rick
int beginBody = result.IndexOf("<table");
The first reference of that is just after the body line and after that is the form line. So I don't think I'm chopping it off.
The url I'm reading is: http://www.promoplace.com/ws/ws.dll?DistID=4637
The end line is:
int endBody = result.Substring(beginBody).IndexOf("<iframe") ;
Rick
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
Re: External page in Content Page?
You can put a conlib in a web page instead of what Able has where they use nVelocity only for the webpage description. You can enter the [[ConLib:xx]] into the webpage description in the admin.
Is there a reason for using an external page? Is it accessed by itself at any time? If not, you can take the form tag out of the external webpage and try it that way. If that doesn't work, here is a forum post about one way of handling it:
viewtopic.php?f=42&t=8322
Is there a reason for using an external page? Is it accessed by itself at any time? If not, you can take the form tag out of the external webpage and try it that way. If that doesn't work, here is a forum post about one way of handling it:
viewtopic.php?f=42&t=8322
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Re: External page in Content Page?
Rick,
There are a number of references on the promoplace page that refer back to the promoplace site. This will complicate using the LoadAPage approach.
The good news is, it looks like you don't mind having the powered by sage text on the page. If you are just trying to bring all the functionality and content of the promoplace page into your site, you can use an <iframe>. To do this, instead of calling the LoadAPage ConLib control, put this into the content for your page:
You can adjust the different values so the information fits in your page. Take a look at this page for more info on the iframe parameters:
http://www.w3schools.com/tags/tag_iframe.asp
There are a number of references on the promoplace page that refer back to the promoplace site. This will complicate using the LoadAPage approach.
The good news is, it looks like you don't mind having the powered by sage text on the page. If you are just trying to bring all the functionality and content of the promoplace page into your site, you can use an <iframe>. To do this, instead of calling the LoadAPage ConLib control, put this into the content for your page:
Code: Select all
<iframe src="http://www.promoplace.com/ws/ws.dll?DistID=4637" height="900px" width="750px" frameborder="0" scrolling="no"></iframe>
http://www.w3schools.com/tags/tag_iframe.asp