Etomite Community Forums: [Resolved]Additional attribute for a document - Etomite Community Forums

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

[Resolved]Additional attribute for a document Rate Topic: -----

#1 User is offline   Christoph 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 6
  • Joined: 20-December 08

Posted 14 April 2009 - 09:50 AM

Hi!

Maybe someone can help me:
I need an additional input field, when I edit a document. I want to include special CSS files that should only be included into one document. I don't want to put them into the <head> section of the template because they're just used some times and shouldn't be loaded, when they're not needed. I could put it into the particular content into the <body> tags but this doesn't fit with XHTML Strict.

Any idea?

thanks Christoph

*edit:
I imagine something like that:

<html>
<head>
<link src="..." name="..." />
[*additionalCSS*]
</head>

...
</html>

In the backend I can define where those additional files are located

I hope you know what I mean

This post has been edited by Christoph: 14 April 2009 - 09:56 AM


#2 User is offline   DeanC 

  • Etomite Administrator
  • Icon
  • Group: Admin
  • Posts: 4,702
  • Joined: 08-June 04
  • Gender:Male
  • Location:United Kingdom

Posted 14 April 2009 - 10:11 AM

It's not currently possible, but you could write a snippet that detects the ID of the page and then loads the files that you want....

#3 User is offline   Christoph 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 6
  • Joined: 20-December 08

Posted 14 April 2009 - 10:34 AM

View PostDeanC, on Apr 14 2009, 11:11 AM, said:

It's not currently possible, but you could write a snippet that detects the ID of the page and then loads the files that you want....


Ah... That's a good idea. I will create a new Table with the assignments.

I also searched a while an found this topic:
http://www.etomite.c...p?showtopic=809

It seems to be a fix for my problem, but the attached file is not accessable.

#4 User is offline   DeanC 

  • Etomite Administrator
  • Icon
  • Group: Admin
  • Posts: 4,702
  • Joined: 08-June 04
  • Gender:Male
  • Location:United Kingdom

Posted 14 April 2009 - 12:46 PM

That file doesn't work for any version of eto except 0.6.0... and hasn't been available for a looooong time.

I wouldn't go to the hassle of creating tables etc and making extra queries to the database... I'd create a snippet that was along the lines of this:

$id = isset($id) ? $id : $etomite->documentIdentifier;
if(($id=="63") || ($id=="65") || ($id=="66") || ($id=="67") || ($id=="68") || ($id=="69") || ($id=="70") || ($id=="71") || ($id=="72") || ($id=="73") || ($id=="74") || ($id=="75") || ($id=="76") || ($id=="77") || ($id=="78") || ($id=="79")) {
	$output = "this is outputted if id equals any of above";
}
return $output;


just change the numbers to equal the id's that you wish the output to display on.... you can then do different versions for different outputs.

#5 User is offline   Ralph 

  • Etomite Administrator
  • Icon
  • Group: Admin
  • Posts: 6,370
  • Joined: 01-July 04
  • Gender:Male
  • Location:Jamestown, NY USA
  • Interests:Computers, Camping, Hiking, Aviation

Posted 14 April 2009 - 02:17 PM

A much more elegant method of implementing Deans code would be...

// the document  document id to check for
 $needle = isset($id) ? $id : $etomite->documentIdentifier;
 
 // the list of valid document id's
 $haystack = array(12,14,17,23,43,55, 58);
 
 if(in_array($needle, $haystack))
 {
   ... do something ...
 }
 else
 {
   ... optionally do something else ...
 }


Another option would be to check for a documents parent if all folder children will use the same styles... There are several ways to locate a documents parent... The easiest way is to use $parent = $etomite->parents[$id];...

#6 User is offline   Cris D. 

  • Loves Etomite Forums!
  • PipPipPipPip
  • Group: Member
  • Posts: 1,063
  • Joined: 10-August 06
  • Location:Brisbane, Queensland, Australia

Posted 14 April 2009 - 04:40 PM

What about:

$filePath="templates/optionalcss/";

$fileId=$etomite->documentIdentifier;//or use alias

$file=$fileId.".css"

$output="<link src='".$filePath.$file"' name='".$file."'	 />";
return $output;


Contents of file 26.css:

Quote

/*Optional Css to load for page 26*/
img{
border-color:#000;
}


You could also use the needle - haystack code above to point to a blank css file if not required for the page.

#7 User is offline   DeanC 

  • Etomite Administrator
  • Icon
  • Group: Admin
  • Posts: 4,702
  • Joined: 08-June 04
  • Gender:Male
  • Location:United Kingdom

Posted 14 April 2009 - 07:56 PM

Hey Cris,
Doing it your way, would it mean that every single page'd need a corresponding css file?
If the else bit's removed from ralph's version then blank files wouldn't be needed for non-corresponding pages ;)
Dean :)


If I was doing it, I'd use the following:
// the document  document id to check for
$needle = isset($id) ? $id : $etomite->documentIdentifier;

// the list of valid document id's
$haystack = array(12,14,17,23,43,55, 58);

if(in_array($needle, $haystack))
{
   $output = '<link rel="stylesheet" href="./templates/'.$needle.'.css" type="text/css" media="screen" />';
}
return $output;


#8 User is offline   Cris D. 

  • Loves Etomite Forums!
  • PipPipPipPip
  • Group: Member
  • Posts: 1,063
  • Joined: 10-August 06
  • Location:Brisbane, Queensland, Australia

Posted 14 April 2009 - 10:02 PM

Quote

Doing it your way, would it mean that every single page'd need a corresponding css file?

Well, every single page that needed extra css. I guess it really comes down to whether the added code needs to be repeated on several pages or specific to each page. There are so many ways to skin a cat, I guess it's now up to each user to select the skinning tool depending on whether they want a new rug, scarf or entree.

#9 User is offline   Christoph 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 6
  • Joined: 20-December 08

Posted 15 April 2009 - 05:23 AM

Thanks a lot for your replies!
I will post my code, when it's finished.

#10 User is offline   Christoph 

  • Etomite Forum Newbie
  • Group: Member
  • Posts: 6
  • Joined: 20-December 08

Posted 15 April 2009 - 06:12 AM

Well I decided to put the files into the <head> - they are not as big as I expected :)

But here my code - it worked well:

// Fell free to copy

$out = "";

$specialPages = array(82, 120);

if (in_array($etomite->documentIdentifier, $specialPages)) {
	$cssAssign = array(
		"82" => "jquery.cluetip.css",
		"120" => "jquery.countdown.css"
	);

	$out .= '<link rel="stylesheet" type="text/css" href="/templates/steiger4/styles/' . $cssAssign[$etomite->documentIdentifier] . '" />';
}

return $out;

This post has been edited by Ralph: 15 April 2009 - 01:49 PM
Reason for edit: Enclosed code example in code tags.


#11 User is offline   DeanC 

  • Etomite Administrator
  • Icon
  • Group: Admin
  • Posts: 4,702
  • Joined: 08-June 04
  • Gender:Male
  • Location:United Kingdom

Posted 15 April 2009 - 07:31 AM

Support Issue Resolved!

The issue this topic was opened for has been resolved, and we look forward to helping you in the future. If you need further assistance, please open a new topic.

This topic will now be marked as Resolved. If you are satisfied with the support provided here at Etomite (or just appreciate the service we provide), you may want to make a donation to help cover forum and server costs in order to help this quality support continue. If you wish to donate, click Here

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users