Part of the EllisLab Network
pMachine Pro has been replaced by ExpressionEngine, our full featured web publishing solution. Please consider upgrading.
You can download pMachine Pro here: Download pMachine Pro  |  Download Language Packs
   
 
Stripping code from blog entry title for window title
Posted: 22 July 2004 02:21 PM   [ Ignore ]  
Summer Student
Total Posts:  19
Joined  2003-07-22

When viewing the web page for a specific blog entry, the contents of the “Title” field are also used as the window title for the web browser window.

The problem with this is that, while HTML code can be used to format certain words in blog entry titles, such code is not allowed in window titles, according to the W3C spec:

http://www.w3.org/TR/html4/struct/global.html#h-7.4.2:

I realize that at least some people will recommend against using any code in the “Title” field, but I don’t see why we should be so backward about it, when using inline tags in headings is perfectly correct in HTML 4.

My question is: Is there a way to automatically remove such code from the contents of the “Title” field when using it as window title?

Right now, I am using

<?php show_field($id,"title"); ?>

in my HTML file for a single entry page, and obviously pMachine replaces this with the full contents of the “Title” field, including whatever HTML code I might have used.

I know that there is already something that strips HTML code from blog entries when displaying them in the “Recent Comments” hack that I use with pMachine. But I don’t know enough about PHP to know whether this could be used here as well, and how.

TIA

Profile
 
 
Posted: 23 July 2004 12:11 PM   [ Ignore ]   [ # 1 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9868
Joined  2002-06-19

Try this:

<?php

ob_start
();
show_field($id,"title");
$title = ob_get_contents();
ob_end_clean();

echo
strip_tags($title);

?>

That should echo/display the title with any HTML (or PHP) tags stripped out.

 Signature 

Chris Curtis
chriscurtis.org

Profile
 
 
Posted: 23 July 2004 02:06 PM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  19
Joined  2003-07-22

Fantastic! This does the trick. Many thanks!

Profile
 
 
Posted: 25 August 2004 12:50 PM   [ Ignore ]   [ # 3 ]  
Research Assistant
RankRankRank
Total Posts:  527
Joined  2003-02-25

Can I somehow stip out the html code from the %%body%% variable to include that in the table’s title field?

Profile
 
 
Posted: 25 August 2004 10:45 PM   [ Ignore ]   [ # 4 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9868
Joined  2002-06-19

Use the above, except switch out “body” for “title”.

 Signature 

Chris Curtis
chriscurtis.org

Profile
 
 
Posted: 24 November 2004 10:21 AM   [ Ignore ]   [ # 5 ]  
Summer Student
Total Posts:  16
Joined  2003-09-11

is there also a way to ‘name’ a particular ‘weblog’ using this technique??

thanks in advance for any help! and have a happy t-day

Profile
 
 
Posted: 24 November 2004 01:46 PM   [ Ignore ]   [ # 6 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9868
Joined  2002-06-19

Sorry, I don’t understand what you’re asking, timmah.  Could you elaborate?

 Signature 

Chris Curtis
chriscurtis.org

Profile
 
 
Posted: 30 November 2004 09:47 AM   [ Ignore ]   [ # 7 ]  
Summer Student
Total Posts:  16
Joined  2003-09-11

hi chris….
the question is how to get the title to automatically show up in the <TITLE> field in the <Header>.

“When viewing the web page for a specific blog entry, the contents of the “Title” field are also used as the window title for the web browser window.”

seems like this *should* work:
<?php show_field($id,“which”); ?>

but it doesn’t seem to want to work with multiple weblogs.
what’s the correct way chris?

thanks a bunch for your help!

Profile
 
 
Posted: 30 November 2004 09:48 AM   [ Ignore ]   [ # 8 ]  
Summer Student
Total Posts:  16
Joined  2003-09-11

oops…..obviously changing “which” to “title”  ....

Profile
 
 
Posted: 30 November 2004 01:42 PM   [ Ignore ]   [ # 9 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9868
Joined  2002-06-19

The “show_field” pM Tag is only available when you’re viewing a “single-entry” type page (such as a comments or more page).

 Signature 

Chris Curtis
chriscurtis.org

Profile
 
 
Posted: 30 November 2004 07:44 PM   [ Ignore ]   [ # 10 ]  
Summer Student
Total Posts:  16
Joined  2003-09-11

so chris….
what ‘tag’ or ‘hack’ would you recommend in an ‘automated’ <Title> for the browser name of a page?

as an example: check out www.LiveOakProjects.com and click on the links.
see how the <Title> name in the browser changes to the title of the post including the category? that blog, being with pMachine Free has only 1 weblog.

problem is using pmachine tags with multiple weblogs.

Profile
 
 
Posted: 01 December 2004 12:26 AM   [ Ignore ]   [ # 11 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9868
Joined  2002-06-19

I still don’t know what it is you want to do, timmah.  You can already have the entry title in your <title>, but that’s only applicable on a “single-entry” page.

What else is it you want?

 Signature 

Chris Curtis
chriscurtis.org

Profile
 
 
Posted: 01 December 2004 04:04 PM   [ Ignore ]   [ # 12 ]  
Summer Student
Total Posts:  16
Joined  2003-09-11

hi again chris,
i’ve tried to figure out how to make my question as easy as possible so here goes:

how do you recommend getting the <Title> automated, even on “multi-entry” pages?

i’m just trying to figure out a way to get the <Title> ‘automated’.

maybe i need to use Categories and use that ‘tag’ to get it done.

whatta ya think chris?

Profile
 
 
Posted: 01 December 2004 07:48 PM   [ Ignore ]   [ # 13 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9868
Joined  2002-06-19

What is it that you want to appear in the <title>?  You haven’t said yet.

If you’re on a multi-entry page then obviously you can’t just say “the entry title” since there are multiple entries displaying.  So, what do you want there?

 Signature 

Chris Curtis
chriscurtis.org

Profile
 
 
Posted: 02 December 2004 09:54 AM   [ Ignore ]   [ # 14 ]  
Summer Student
Total Posts:  16
Joined  2003-09-11

how about this:

should the <?php show_field($id, “WHATEVER”); ?> tag work in the <Title> field when using multiple weblogs?

Profile
 
 
Posted: 02 December 2004 12:58 PM   [ Ignore ]   [ # 15 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9868
Joined  2002-06-19

What do you mean by “multiple weblogs”?  Do you really mean “when displaying multiple entries from a weblog on the same page”?  If so, the answer is “no” as I mentioned previously.

If that’s not what you mean, then you’ll need to explain yourself more.

 Signature 

Chris Curtis
chriscurtis.org

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 233, on December 18, 2007 12:04 AM
Total Registered Members: 64518 Total Logged-in Users: 0
Total Topics: 81078 Total Anonymous Users: 0
Total Replies: 436319 Total Guests: 14
Total Posts: 517397    
Members ( View Memberlist )
Active Members: