Documenting / Sharing Templates
Posted: 03 September 2006 03:22 AM   [ Ignore ]  
Lab Assistant
RankRank
Total Posts:  163
Joined  02-17-2004

I would like to build a page at microlens.net that documents how I built my photo gallery.  I would like to show each of my templates in a manner similar to what pMachine does.  Using this template library page as an example, how can I best convert the template code within the box into machine readable code?  Would this be the purpose of Paul Burdick’s “HTML Strip” plug-in?  Or, is there another method that’s suggested?

Thanks for your help.

 Signature 

John Mansfield
cellMatrix.net
EE Version 1.6.5 - Build: 20081031

Profile
 
 
Posted: 03 September 2006 10:08 AM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23521
Joined  05-20-2002

You lost me a bit.  You just want to show the template code in a textarea?  And do it via a post?  Or have it dynamically generated via a template?

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 03 September 2006 11:49 AM   [ Ignore ]   [ # 2 ]  
Lab Assistant
RankRank
Total Posts:  163
Joined  02-17-2004

I’m just wanting to show template code within a text area of that template.  I would like to set up one page similar to how the pMachine site shows their templates.  I’m wondering if there’s a way within EE to convert things like < (less than), > (greater than), ” (quote), etc. so that they look like their symbols in the template.  I’ve tried the “code” tag but that doesn’t seem to work.

 Signature 

John Mansfield
cellMatrix.net
EE Version 1.6.5 - Build: 20081031

Profile
 
 
Posted: 03 September 2006 12:43 PM   [ Ignore ]   [ # 3 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23521
Joined  05-20-2002

Can you give me an example of what you’re doing now?  The code?

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 03 September 2006 07:34 PM   [ Ignore ]   [ # 4 ]  
Lab Assistant
RankRank
Total Posts:  163
Joined  02-17-2004

I’m not really doing anything now - just wondering about how I can do it.  After thinking about it I think it could be dynamically generated via a template as you first suggested.

For example, in the pMachine template library choose any template.  There are links for “view”, “source”, and “download”.  Click on the “source” link.  The tags/code for the index, comments, CSS, etc. will appear in text boxes.  The textbox allows you to copy the template code directly from the pMachine site to yours.  That is the functionality that I would like to build into one of my pages. 

Again at the “source” page, in Internet Explorer click on View - Source.  Some of the EE code has been converted to it’s ASCII equivilent characters.  I’ve also noticed that when I’m in the EE control panel -> template section -> that I can choose any of my templates, click View - Source, and that template contains certain characters that have been converted to their ASCII equivilent characters.  Because the templates allow you to continually make changes, I think it can probably be done dynamically.

In a nutshell, I’m wondering if there’s a plug-in that automatically converts certain characters to their ASCII equivilents.  I wasn’t totally understanding Pauls “HTML Strip” plug-in but was wondering if that was what it is for.  Or, is there some other suggested method.

I guess I could always replace the characters with their ASCII equivilents by copying the code into MS Word and using Find-Replace.  However, it looks like EE is automatically doing it within the program.  I just wondering how and if I can apply it to my page.

Thanks again for your help.

 Signature 

John Mansfield
cellMatrix.net
EE Version 1.6.5 - Build: 20081031

Profile
 
 
Posted: 04 September 2006 08:59 AM   [ Ignore ]   [ # 5 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23521
Joined  05-20-2002

I’m not dead sure you need to convert anything- not if the goal is just to show exactly what’s in a template.  I did this:

<?php
global $DB;
$sql="SELECT template_data, template_name FROM exp_templates WHERE template_id=1 OR template_id = 250";
$results = $DB->query($sql);
foreach (
$results->result as $row)
{
echo '<h2>'.$row['template_name'].'</h2>';
echo
'<textarea cols="100" rows="20">'.$row['template_data'];
echo
'</textarea><br>';
}
?>


Stuck it in a template- results in this- which is in the ballpark of what you want- correct?  The query module jammed up a bit with it- that’s why I went with php.

Anyway- depending on what you’re going for, something like this approach would be pretty easy.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 04 September 2006 09:56 AM   [ Ignore ]   [ # 6 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  759
Joined  03-22-2004

Nice tip!

Profile
 
 
Posted: 04 September 2006 11:04 AM   [ Ignore ]   [ # 7 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23521
Joined  05-20-2002

Hm- except the embeds are being parsed- and not even switching the brackets out for entities fixes it.  Nor does parse order.  Hm- I wonder if doing it as a plugin would matter.  I’ll dink with it a bit and see.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 04 September 2006 11:10 AM   [ Ignore ]   [ # 8 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23521
Joined  05-20-2002

Heh- it was the textarea html in one of the forms that kept throwing things off- but replacing the >‘s took care of that as well.  So:

<?php
global $DB;
$sql="SELECT template_data, template_name FROM exp_templates WHERE template_id=1 OR template_id = 250";
$results = $DB->query($sql);
$info = '';
foreach (
$results->result as $row)
{
$template
=  str_replace(array('{', '}', '<', '>'), array('{', '}', '&#60;', '&#62;'), $row['template_data']);
echo
'<h2>'.$row['template_name'].'</h2>';
echo
'<textarea cols="100" rows="20">'.$template;
echo
'</textarea><br>';
}

?>


That seems to work- proper display, nothing parsed.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 06 September 2006 06:15 AM   [ Ignore ]   [ # 9 ]  
Lab Assistant
RankRank
Total Posts:  163
Joined  02-17-2004

Robin - thank you!! - that’s just what I’m looking for.  I appreciate your time and effort in writing the php.  I’ll try to add it to my site this weekend.

Thanks again.

 Signature 

John Mansfield
cellMatrix.net
EE Version 1.6.5 - Build: 20081031

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 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64881 Total Logged-in Users: 55
Total Topics: 81808 Total Anonymous Users: 41
Total Replies: 439771 Total Guests: 299
Total Posts: 521579    
Members ( View Memberlist )
Newest Members:  Dynamic1justingpticketjendicottdxrsmdanbilly8hrkiliwysso50kexpressoKlaas