Developer forum

Forum » Development » pageView.Meta.Title returns wrong text

pageView.Meta.Title returns wrong text

Casper Stendal
Reply
Hi,

We are have a custom module creating custom PDF documents from pages.

We would like to get the meta-title from a page, based on the pageid, and use this for the PDF filename.

We have tested this code:
int PageID = Base.ChkInteger(Base.Request("PageID"));
PageView pageView = PageView.GetPageviewByPageID(PageID);
string pagename = pageView.Meta.Title + "_" + PageID;

The PageID is just fine and returns the correct integer, but the pageView.Meta.Title returns "Dynamicweb 7", no matter what the PageID is and even though we have a different Titel set on the page i DW admin !?!?

Best regards
Casper Stendal

Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
Hi Casper,

Sounds like an issue I had some time ago. Turned out my Default.aspx and Global.asax were not set up correctly. Which version of DW are you using? Is this set up as a custom solution and if so, can you post the code for two patges mentioned?
 

Cheers,

Imar

 
Casper Stendal
Reply

Hi Imar,

Heres the Default.aspx.cs:
 

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 Dynamicweb;
using Dynamicweb.Frontend;

namespace CustomModules
{
	public partial class Default : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			//Set a timer to monitor performance
			long StartTime = DateTime.Now.Ticks;
			//Initiate the pageview object that handles a Page view in Dynamicweb
			Dynamicweb.Frontend.PageView Pageview = new Dynamicweb.Frontend.PageView();

			//Create an instance of the eventhandler object and attach it to the custom module event
			//OBSOLETE START
			//CustomModuleHandler objCustModuleHandler = new CustomModuleHandler();
			//Pageview.Content.CMEventHandler += objCustModuleHandler.GetCustomModule;
			//OBSOLETE END

			//Load data, templates and settings in the pageview object
			Pageview.Load();

			Dynamicweb.Frontend.PageviewControl pvCtrl = new Dynamicweb.Frontend.PageviewControl();
			Output.Controls.Add(pvCtrl);
			pvCtrl.Pageview = Pageview;
			pvCtrl.ParseControls();

			//Output.Text = Pageview.Output();

			//Collect the last performance counter and print if requested
			Pageview.Execution.Add("After output");
			string strDebug = Base.ChkString(Base.Request("Debug"));
			if (strDebug == "True")
			{
				Status.Text = Server.HtmlEncode("<!-- Exe time: " + Convert.ToString((DateTime.Now.Ticks - StartTime) / 10000000 + " " + Pageview.StatusText.ToString() + " -->") + Pageview.Execution.getExecutionTable() + Pageview.OutputPages());
			}
			else
			{
				Status.Text = "<!-- Exe time: " + Convert.ToString((DateTime.Now.Ticks - StartTime) / 10000000) + " " + Pageview.StatusText.ToString() + " -->";
			}
		}
	}

	public class CustomModuleHandler
	{
		public void GetCustomModule(object sender, Dynamicweb.Frontend.CustomModuleEventArgs e)
		{
			string strModuleName = e.Name;
			switch (strModuleName)
			{
				default:
					e.Output = "<font color=\"red\">ERROR!</font> \"" + strModuleName + "\" is an unknown module system name";
					break;
			}
		}
	}
}


And here's the Global.asax.cs:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;

namespace CustomModules
{
	public class Global : System.Web.HttpApplication
	{

		Dynamicweb.Admin.Global GlobalAsax = new Dynamicweb.Admin.Global();
		public void Application_Start(object sender, EventArgs e)
		{
			// Fires when the application is started
			GlobalAsax.Application_Start(sender, e);
			
            //Below outcommented by msn@dynamicweb.dk, 08-April-2010
            //Dynamicweb.ScheduledTask.Thread.Start();
		}

		public void Session_Start(object sender, EventArgs e)
		{
			// Fires when the session is started
			GlobalAsax.Session_Start(sender, e);
		}

		public void Application_BeginRequest(object sender, EventArgs e)
		{
			// Fires at the beginning of each request
			//GlobalAsax.Application_BeginRequest(sender, e);
		}

		public void Application_AuthenticateRequest(object sender, EventArgs e)
		{
			// Fires upon attempting to authenticate the use
			GlobalAsax.Application_AuthenticateRequest(sender, e);
		}

		public void Application_Error(object sender, EventArgs e)
		{
			// Fires when an error occurs
			GlobalAsax.Application_Error(sender, e);
		}

		public void Session_End(object sender, EventArgs e)
		{
			// Fires when the session ends
			GlobalAsax.Session_End(sender, e);
		}

		public void Application_End(object sender, EventArgs e)
		{
			// Fires when the application ends
			GlobalAsax.Application_End(sender, e);
		}

		public void Application_OnPreRequestHandlerExecute(object sender, EventArgs e)
		{
			GlobalAsax.Application_OnPreRequestHandlerExecute(sender, e);
		}
	}
}


Current version: 19.2.9.4

Hope you can see something from that?

Best regards
Casper Stendal
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
This post has been marked as an answer
Hmmm, I think for 7.2 that looks right to me. I had that issue on DW 8.

I think it's a bug. I can reproduce this on DW 8 with the proper files in place. In my situation the titles ended up in the brwoser, and that has been fixed, but it seems a similar problem is now taking place in the API.

I would contact support and report this.

Cheers,

Imar

Votes for this answer: 0
 
Vladimir
Reply

 

You must be logged in to post in the forum