Jump to content


- - - - -

[Resolved]Additional attribute for a document


  • This topic is locked This topic is locked
10 replies to this topic

#1 Christoph

    Etomite Forum Newbie

  • Member
  • 6 posts

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

Edited by Christoph, 14 April 2009 - 09:56 AM.


#2 Dean

    Loves Etomite Forums!

  • Admin
  • 4,746 posts
  • Gender:Male

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 Christoph

    Etomite Forum Newbie

  • Member
  • 6 posts

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 Dean

    Loves Etomite Forums!

  • Admin
  • 4,746 posts
  • Gender:Male

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 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,505 posts
  • Gender:Male

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 Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts
  • Gender:Male

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 Dean

    Loves Etomite Forums!

  • Admin
  • 4,746 posts
  • Gender:Male

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 Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts
  • Gender:Male

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 Christoph

    Etomite Forum Newbie

  • Member
  • 6 posts

Posted 15 April 2009 - 05:23 AM

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

#10 Christoph

    Etomite Forum Newbie

  • Member
  • 6 posts

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;

Edited by Ralph, 15 April 2009 - 01:49 PM.
Enclosed code example in code tags.


#11 Dean

    Loves Etomite Forums!

  • Admin
  • 4,746 posts
  • Gender:Male

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





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users