Just a thought if it is possible to inspect the rendered result view from controller

34 views
Skip to first unread message

Peter Pham

unread,
Mar 21, 2011, 1:26:37 AM3/21/11
to framework-one
For example, I have view called 'page1.cfm' with following content:

<h1>FAQ</h1>
<p>Lorem ipsum ..... </p>

The page will be called by show.cfc controller .
Although I can manual set rc.pagetitle at any time in the controller
or the view, however,
I want the show.cfc controller to auto-set page title by using the
first <h1> that it finds.
I thought that I might use like this:

function after(rc) {

viewresult = fw.view( fw.getFullyQualifiedAction() );
rc.pagetitle = customFunctionToExtractHeading( viewresult );

}

Apparently, framework-one does not allow the view to be called at this
stage.
I understand why it should behave this way, but,
just want to know if there is workaround to inspect result of the
view ?
Not a big deal if it is not achievable.

FYI: the reason why I want to do it this way because my view only
contains HTML (and hopefully can be freely added/edited by common
users who are trained with HTML); as they may add more page(s)/view(s)
so I simply want the page title to be detected immediately rather than
for me to manually set page title for every views.

Sean Corfield

unread,
Mar 21, 2011, 1:42:52 AM3/21/11
to framew...@googlegroups.com
Views are rendered AFTER controllers have run. Please see the request
lifecycle documentation.

I guess you could add logic to your layout to look for an h1 in the
body and set the page title from that? (but I think it's a horrible
hack)

Peter Pham

unread,
Mar 21, 2011, 2:10:37 AM3/21/11
to framework-one
True. I guess it is not worth to do so.
Thanks for fast reply.

Curt Gratz

unread,
Mar 21, 2011, 4:40:51 PM3/21/11
to framew...@googlegroups.com, Peter Pham
You could use some simple jQuery to set the page title from the H1.  Something like this should work.

$('title').text($('h1:first').text());

Hope that helps,
Curt Gratz
Computer Know How

Sean Corfield

unread,
Mar 21, 2011, 6:20:28 PM3/21/11
to framew...@googlegroups.com
jQuery rocks! Thank you Curt! Yes, fixing up the DOM in the browser is
a much better way to handle this than trying to do anything
server-side.

Sean


--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

Peter Pham

unread,
Mar 21, 2011, 7:35:33 PM3/21/11
to framework-one
Thanks, Curt.
jQuery was my ideal option.
However, the reason to set page title is mainly for SEO purpose.
Don't think jQuery is better though.

On Mar 22, 9:20 am, Sean Corfield <seancorfi...@gmail.com> wrote:
> jQuery rocks! Thank you Curt! Yes, fixing up the DOM in the browser is
> a much better way to handle this than trying to do anything
> server-side.
>
> Sean
>
> On Monday, March 21, 2011, Curt Gratz <gra...@compknowhow.com> wrote:
> > You could use some simple jQuery to set the page title from the H1.  Something like this should work.
> > $('title').text($('h1:first').text());
>
> > Hope that helps,Curt GratzComputer Know How
>
> --
> Sean A Corfield -- (904) 302-SEAN
> An Architect's View --http://corfield.org/
> World Singles, LLC. --http://worldsingles.com/
> Railo Technologies, Inc. --http://www.getrailo.com/

Sean Corfield

unread,
Mar 21, 2011, 8:35:30 PM3/21/11
to framew...@googlegroups.com
On Mon, Mar 21, 2011 at 4:35 PM, Peter Pham <vdung...@gmail.com> wrote:
> However, the reason to set page title is mainly for SEO purpose.

Well, I doubt that - in general - the first h1 on a page is going to
be all that useful as an SEO title so I would think you really would
want the page title separate.

Also, from a bookmarking / navigation p.o.v. your users would probably
prefer the page title be Site Name - Section Name - Page Name rather
than just some heading text - otherwise how will they tell sites apart
in their bookmarks or history?

Just my 2¢...


--
Sean A Corfield -- (904) 302-SEAN

An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

Railo Technologies, Inc. -- http://www.getrailo.com/

Jamie Krug

unread,
Mar 21, 2011, 8:43:06 PM3/21/11
to framew...@googlegroups.com, Peter Pham
Right, jQuery is of course awesome for DOM manipulation and user experience, but no help on SEO for the HTML title. Peter, since you mention that you're dealing with plain HTML that will be uploaded by "non-developer" users, maybe that simply needs to be represented in and retrieved by your model somehow, rather than it being an FW/1 view? For example, you might call upon a service method, passing an ID or pageName type argument; the service method maybe returns a struct that contains "title" and "body" keys. So, maybe a page.cfc:render() controller method looks something like this...

function render( rc )
{
    var page = getPageService().getPage( rc.pageID );
    rc.title = page.title;
    rc.body = page.body;
}

Then, your layout (or whatever) can access the title via the request context, and the view can get the body HTML from the RC as well.

Lots of options, but hopefully this gives you some alternatives to ponder?

Best,
Jamie

Jamie Krug

unread,
Mar 21, 2011, 8:51:11 PM3/21/11
to framew...@googlegroups.com, Sean Corfield
On Monday, March 21, 2011 8:35:30 PM UTC-4, Sean Corfield wrote:
On Mon, Mar 21, 2011 at 4:35 PM, Peter Pham <vdung...@gmail.com> wrote:
> However, the reason to set page title is mainly for SEO purpose.

Well, I doubt that - in general - the first h1 on a page is going to
be all that useful as an SEO title so I would think you really would
want the page title separate.

The h1 does have some serious SEO significance, and "the first h1" should actually throw a red flag, because SEO best practices would recommend one and only one h1 on a page.

Also, from a bookmarking / navigation p.o.v. your users would probably
prefer the page title be Site Name - Section Name - Page Name rather
than just some heading text - otherwise how will they tell sites apart
in their bookmarks or history?

Having keyword(s) in the h1 and HTML title does provide SEO benefits, however, I completely agree on your suggested convention for user friendly bookmarking. A dynamic title string (from the h1) could still be used as _part_ of the HTML title (i.e., the "Page Name" part of the "Site Name - Section Name - Page Name" suggestion). Personally, I might prefer the inverse: "Page Name - Section Name | Site Name," which may also be slightly preferred by an SEO, assuming there's some "keyword power" in the "Page Name" part.

I've worked closely with an SEO on our team recently, so I've had some interesting challenges to cleanly integrate usability with both SEO needs and good application design :P

Cheers,
Jamie

Sean Corfield

unread,
Mar 21, 2011, 10:20:24 PM3/21/11
to framew...@googlegroups.com
On Mon, Mar 21, 2011 at 5:51 PM, Jamie Krug <jami...@gmail.com> wrote:
> The h1 does have some serious SEO significance

Really? Is there some definitive documentation on what works for SEO
these days? I see so much snake oil and bollocks posted about SEO that
I've become ever so cynical...

(I agree about just one H1 tho' for semantic web purposes)

> Personally, I might prefer the
> inverse: "Page Name - Section Name | Site Name," which may also be slightly
> preferred by an SEO, assuming there's some "keyword power" in the "Page
> Name" part.

Someone told me recently that search engines only pay attention to the
first N characters (or was it the first M words?) of a page title so
you could be right there.

Eapen

unread,
Mar 21, 2011, 10:40:01 PM3/21/11
to framew...@googlegroups.com
On Mon, Mar 21, 2011 at 5:51 PM, Jamie Krug <jami...@gmail.com> wrote:
> The h1 does have some serious SEO significance

Really? Is there some definitive documentation on what works for SEO
these days? I see so much snake oil and bollocks posted about SEO that
I've become ever so cynical...

From what I've read also, the first h1 tag is given very high priority, probably right after the title of the page.

> Personally, I might prefer the
> inverse: "Page Name - Section Name | Site Name," which may also be slightly
> preferred by an SEO, assuming there's some "keyword power" in the "Page
> Name" part.

Someone told me recently that search engines only pay attention to the
first N characters (or was it the first M words?) of a page title so
you could be right there.
 
Yep, if you look at the search engine results, it usually only shows the first X characters and then the ellipsis. So, if you have a long Site name, it usually obscure the more meaningful page title. Additionally, it also helps to separate the page name from the section title with a comma (if it makes sense).

Jamie Krug

unread,
Mar 22, 2011, 9:41:20 AM3/22/11
to framew...@googlegroups.com
FWIW, a quick search-and-skim shows that many folks highly recommend giving attention to title and heading tags, but there's also evidence that the value in SEO/search engine ranking is unproven, or even a myth. Google's own Search Engine Optimization Starter Guide does highlight a "Use heading tags appropriately" section, but it does not give any evidence of what benefit it has in their ranking algorithm (no surprise there).

Best,
Jamie


--
FW/1 on RIAForge: http://fw1.riaforge.org/
 
FW/1 on github: http://github.com/seancorfield/fw1
 
FW/1 on Google Groups: http://groups.google.com/group/framework-one

Sean Corfield

unread,
Mar 22, 2011, 12:19:37 PM3/22/11
to framew...@googlegroups.com
On Mon, Mar 21, 2011 at 7:40 PM, Eapen <gea...@gmail.com> wrote:
> From what I've read also, the first h1 tag is given very high priority,
> probably right after the title of the page.

Read _where_?

I hear a lot of this sort of stuff about SEO but mostly folks refer to
blogs which have just opinions. I'm looking for good, solid, provable
(or proven) technical information on this stuff.

> Yep, if you look at the search engine results, it usually only shows the
> first X characters and then the ellipsis.

Just because search engines choose to display it like that does NOT
mean that's all they look at. That's exactly the sort of "fluff" I'm
railing against here.

Jamie Krug

unread,
Mar 22, 2011, 2:15:50 PM3/22/11
to framew...@googlegroups.com, Sean Corfield
On Tue, Mar 22, 2011 at 12:19 PM, Sean Corfield <seanco...@gmail.com> wrote:
I hear a lot of this sort of stuff about SEO but mostly folks refer to
blogs which have just opinions. I'm looking for good, solid, provable
(or proven) technical information on this stuff.

Yes, indeed! Part of this likely stems from the fact that Google (and other search engines) are much less than forthcoming with details about their ranking algorithms. That said, there seem to be some good general best practices and techniques that are consistently agreed upon by very experienced SEOers. Google also publishes a fair amount of best practices type stuff. SEOmoz seems to be a very well regarded resource, and sure they're in business to make some money on their SEO software/services, but they also provide a lot of learning resources. They also produce an annual Search Engine Ranking Factors report, which is the results of extensive surveys completed by 72 top worldwide SEO experts. Of course, I don't know who these "SEO experts" are, or how they're identified, but I expect there's a reasonable level of validity to this report. FWIW, "Keyword Use Anywhere in the H1 Headline Tag" is ranked #4 under the On-Page (Keyword-Specific) Ranking Factors.
 
> Yep, if you look at the search engine results, it usually only shows the
> first X characters and then the ellipsis.

Just because search engines choose to display it like that does NOT
mean that's all they look at. That's exactly the sort of "fluff" I'm
railing against here.

Agreed. If you look back, my earlier mention of the title style was merely a personal preference, with the benefit being visibility of the specific topic at the _beginning_ of the title, and therefore my bookmarks. I have no idea whether a keyword near the beginning or end of a title has any real SEO significance.

Okay, enough of that--I'll let the "SEO experts" battle out the finer details. I'm going to get back to some coding with Framework One ;-)

Cheers,
Jamie

Eapen

unread,
Mar 22, 2011, 3:20:23 PM3/22/11
to framew...@googlegroups.com, Sean Corfield

On Tuesday, March 22, 2011 12:19:37 PM UTC-4, Sean Corfield wrote:
On Mon, Mar 21, 2011 at 7:40 PM, Eapen <gea...@gmail.com> wrote:
> From what I've read also, the first h1 tag is given very high priority,
> probably right after the title of the page.

Read _where_?

I hear a lot of this sort of stuff about SEO but mostly folks refer to
blogs which have just opinions. I'm looking for good, solid, provable
(or proven) technical information on this stuff.

Agreed that this is stuff I've read from SEO "experts" posts on various blogs and it is more of a "best practice" than a hard rule. 
One other good resource for SEO optimization is Google's own SEO Guide - http://www.google.com/webmasters/docs/search-engine-optimization-starter-guide.pdf

It also makes sense that the prominent heading would be relevant for a webpage given that it is likely to be unique for a given webpage and will be relevant to the content of the page. 

> Yep, if you look at the search engine results, it usually only shows the
> first X characters and then the ellipsis.

Just because search engines choose to display it like that does NOT
mean that's all they look at. That's exactly the sort of "fluff" I'm
railing against here.

The point I was trying to make (but conveniently didn't explain) is that Google tends to value "click-through"s highly for a given search result. So, if a search for "baseball cards" shows me a results like "MyLongName's Random Thoughts | How I made a million...." vs "How I made a million bucks with Baseball Cards | My L...", I am more likely to click the second result and if a hundred others did the same, Google would give greater importance to the second result and push up its Page Rank. 

On a separate note, the best ROI for SEO is getting links from pages with high PageRanks and other sites legitimately. JC Penney was recently penalized for using this in a wrongful manner - although I am sure their efforts paid off since their search results dominated a lot of keywords over the holiday season.

Sean Corfield

unread,
Mar 22, 2011, 12:25:52 PM3/22/11
to framew...@googlegroups.com
On Tue, Mar 22, 2011 at 6:41 AM, Jamie Krug <ja...@thekrugs.com> wrote:
> there's also evidence that the
> value in SEO/search engine ranking is unproven, or even a myth.

My point exactly :)

> Google's own
> Search Engine Optimization Starter Guide does highlight a "Use heading tags
> appropriately" section, but it does not give any evidence of what benefit it
> has in their ranking algorithm (no surprise there).

Well, using the <hN> tags properly is about structural markup,
semantic web and making pages more accessible - page readers use the
headings to help users navigate around on a page - and there are tools
out there to summarize web pages that rely heavily on headings
actually being in a proper cascade.

Given everything else in Google's document, I'd actually be surprised
if they used <h1> tags at all - their doc focuses on <title>, metadata
and anchor text.

But, again, so much of this SEO stuff seems like folklore and opinion
to me... and perhaps it will always be that way while search engine
companies remain so secretive about their algorithms?

Reply all
Reply to author
Forward
0 new messages