Our monthly Virtual Happy Hour is happening today (Fri Feb 23)!
Im trying to create an additional report that will locate pages where the metaDescription field has not been declared. Does anyone have a good starting ground? Im using reflector to go through the code for the template reports that are available, but Im unsure how to create a report that will return the relevant pages? Any help would be very welcome. Thanks.
This might be a good place to start or are you asking for how to search for a page property that hasn't been set?
Yes, Im asking how to search for pages that dont have any data for the metaDescription field.
Ok... then I'd do something like this...
1. Get a PageDataCollection. In your case you'd probably want the start page and all it's children. If there are few pages in your site you can use DataFactory.GetDescendents() like DataFactory.GetDescendants(PageReference.StartPage) but theres some performance issues to consider. A better method is DataFactory.FindPagesWithCriteria() or DataFactory.FindAllPagesWithCriteria().
2. Loop over your PageDataCollection and check your property
foreach(PageData objPageData in DataFactory.GetDescendants(PageReference.StartPage))
if(objPageData["YourProperty"] == null)
// Do something with objPageData here
You might wanna check if objPageData["YourProperty"].ToString() == String.Empty as well...
Hope this helps you...
thanks for the info Henrik...in the end I managed to achieve this purely in markup, with a SearchDataSource, repeater, and a couple of property controls, and then just databound in code behind. Do you have any idea how I can now make the page I have created show up in the report section on the live site? Displays in reports on my local project, but I am unsure what amendments I need to make on the live site to allow it to be displayed in the reports section?
It should just be a matter of copying your files to the server that the live site runs on. I assume you have decorated the class for your report with the attribute "GuiPlugIn" and have set "area=PlugInArea.ReportMenu"? Then just copy your aspx-file and binary to the server and it should appear in the reports.
Exactly what I have done, like I said, works fine on local copy, but is not showing up on the live site.
Ok... there's also a URL-section that you can specify in the GuiPlugIn attribute. This should point to your aspx-file. Is this URL correct for your live site i.e. is the location for your aspx-file the same on your local copy compared to your live site?
Yes, the url points to the root of the site "~/page.aspx", and is in the same location (in the root dir) on both local and live sites.
Incidently, how can I copy over mark up and code behind pages, that I create locally in a project, and then copy over to the production server? As the files I create are on a project that is not the same as the live site, I cant update any of the dll's. For example, I have copied over test.aspx and test.aspx.cs, created a new page type in the CMS on the live server, and pointed the template field to test.aspx. I get the error "could not load type blah.blah.templates.test". I understand why I get the error, but how can I work around this when I cant recompile the site on the live server??? Thanks Henrik.
Ok... then I understand. Your live site has no knowledge of your report since the class isn't in any dll. There is one thing that might work for your test.aspx but I don't recomend it. That is to set the 'CodeFile="yourfile.aspx.cs"' attribute of your aspx-file instead of 'CodeBehind="..."'. This means that your aspx-file will compile on runtime (when requested) as opposed to being precompiled in your dll. There is of course some performance issues doing this but you don't need the live site source code.
In the case of your report the above method wont work since EPiServer scans the binaries in your "bin" folder on startup looking for the "GuiPlugIn" attribute. To add a report you need the source code for the live site or compile a stand-alone dll.
thanks Henrik, although changing CodeBehind to CodeFile stops the loading error, in this case I will also need the source for the project (Im using tinyMCE to allow iframes within the site) which at present, the site is not saving the iframe info that it will on my local project (just converts iframes to non breaking spaces).