Jump to content


- - - - -

[Modification] Document Content Variables


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

#16 stebrennan

    Etomite Forum Newbie

  • Member
  • 18 posts

Posted 08 September 2004 - 09:36 PM

Alex, on Sep 8 2004, 06:17 PM, said:

It's looking pretty good! Content templates will go a little further, by also integrating with access permissions etc. I've got the code done for about 30%, and the theory all worked out.

I'll scan the code sometime soon to see if it's usable, because if it is, I'm pinching it ;)

As content templates are part of 07, which will also have a major manager rewrite, it'll be some time before I can offer those, and this seems to be a very good workaround until then. ;)

Hi there, as promised here is my mod to the mod :D

I will be honest, this has not been fully tested and as I don't yet know the system in any great depth yet, there may be blatant errors or things I have missed out. So in advance - apologies for buggy code.......

You will need to add a new field "field_template" onto the "etomite_docvars_fields" table - type int(11) default 0

I must repeat, this is unbelievably beta code - so be warned

Attached Files



#17 apodigm

    Etomite Forum Newbie

  • Member
  • 41 posts

Posted 09 September 2004 - 01:51 PM

stebrennan, on Sep 9 2004, 03:36 AM, said:

Hi there, as promised here is my mod to the mod  :D

I will be honest, this has not been fully tested and as I don't yet know the system in any great depth yet, there may be blatant errors or things I have missed out. So in advance - apologies for buggy code.......

You will need to add a new field "field_template" onto the "etomite_docvars_fields" table - type int(11) default 0

I must repeat, this is unbelievably beta code - so be warned


I see it. I'll take a look at it tonight and see how it works. At the same time, I'm going to change the mode to give more options for the size of the text areas and htmlareas.

In order to get around the whole problem with templates changing, I'm just going to add an "onchange" script so that if/when someone changes the template, it will reload the page. (hopefully this will not be more complicated than it sounds.)

#18 Dimmy

    Etomite Forum Fan

  • Member
  • Pip
  • 109 posts

Posted 15 September 2004 - 08:40 PM

Would it be posible to ad a extra option to the list called image?

I would like to use this option in my template to get a new picture coresponding whit that page outsite the "normal" [*content*] cell in his own fixed positioned cell in the template

so that the user can upload a picture or get one from the image dir the htmarea upload would be a good one but then without the htmlarea editor
just 1 buton add image and a preview of the image when one is loaded when non new is loaded a standard picture must be displayed what also would be a good feature in this all is the posibility to set fixed image size so that when the user up's a picture thats to big that it will shrink to the fixed size

A big story I hope that some one understands greets Dimmy

#19 apodigm

    Etomite Forum Newbie

  • Member
  • 41 posts

Posted 15 September 2004 - 09:13 PM

Dimmy, on Sep 16 2004, 02:40 AM, said:

Would it be posible to ad a extra option to the list called image?

There is a "file" variable type that you can use with this. Just create a document content variable called image and make the variable data type "file".

You will see it gives you the ability to upload the image into the same "assets" folder that HTMLarea uses for embedded images. There is also a link to the existing image so the user can preview the image.

#20 Dimmy

    Etomite Forum Fan

  • Member
  • Pip
  • 109 posts

Posted 15 September 2004 - 09:48 PM

apodigm, on Sep 15 2004, 11:13 PM, said:

There is a "file" variable type that you can use with this.  Just create a document content variable called  image and make the variable data type "file".

You will see it gives you the ability to upload the image into the same "assets" folder that HTMLarea uses for embedded images.  There is also a link to the existing image so the user can preview the image.

This option gives me some problems when I want to edit that page again the image I uploaded is gone it does not show in the editor another problem is that I also would like to choose a image already uploaded on the server that is also not posible whit the file feaure.

What also would be good is that I do not need to place the <img src=" tag in my template so that when no image is wanted there will no ret cross displayed in that spot.

#21 apodigm

    Etomite Forum Newbie

  • Member
  • 41 posts

Posted 15 September 2004 - 10:15 PM

Dimmy, on Sep 16 2004, 03:48 AM, said:

This option gives me some problems when I want to edit that page again the image I uploaded is gone it does not show in the editor another problem is that I also would like to choose a image already uploaded on the server that is also not posible whit the file feaure.

What also would be good is that I do not need to place the <img src=" tag in my template so that when no image is wanted there will no ret cross displayed in that spot.

I'm not really sure I understand what you are trying to do. It sounds like you are trying to do something that uses the HTMLArea file upload. But perhaps you need to "call" the image for a document from outside the content variable of that document. (which is where the content variable would be used).

If you want to have a separate content variable that stores an image, but lets you use the HTMLArea Image tool, why don't you just create a document variable called "image" but then set the variable type to HTMLArea. That way, you could also prevent the missing image in the event that document doesn't have an image to associate.

#22 Dimmy

    Etomite Forum Fan

  • Member
  • Pip
  • 109 posts

Posted 15 September 2004 - 10:19 PM

apodigm, on Sep 16 2004, 12:15 AM, said:

I'm not really sure I understand what you are trying to do. It sounds like you are trying to do something that uses the HTMLArea file upload.  But perhaps you need to "call" the image for a document from outside the content variable of that document.  (which is where the content variable would be used).

If you want to have a separate content variable that stores an image, but lets you use the HTMLArea Image tool, why don't you just create a document variable called "image" but then set the variable type to HTMLArea. That way, you could also prevent the missing image in the event that document doesn't have an image to associate.


but thatway the options are to much htmarea is not realy fool proof

is there noo ne who is in need for this same item? a imagecontent variable just for images nothing els

Greets Dimmy

#23 kartav

    Etomite Forum Newbie

  • Member
  • 10 posts

Posted 16 September 2004 - 09:30 AM

Please help!
Content Variables are working all right but in snippet they are not working.
E.g. when I insert following code:
$output .= "<p>" . $items[$i]['content_extra'] ."</p>";
in NewsIndex snippet I get nothing - just
<p></p>
Then I change it like this:
$output .= "<p>" . $items[$i]['content'] ."</p>";
everything seems ok.
What can I do?

#24 apodigm

    Etomite Forum Newbie

  • Member
  • 41 posts

Posted 16 September 2004 - 01:48 PM

You should use the new 06 API for this.

$etomite->documentObject['content_extra'];

#25 kartav

    Etomite Forum Newbie

  • Member
  • 10 posts

Posted 17 September 2004 - 08:09 AM

apodigm, on Sep 16 2004, 04:48 PM, said:

You should use the new 06 API for this.

$etomite->documentObject['content_extra'];
Alex,
Would you be so kind to review this code: NewsListing Snippet and to say what it is needed to change to make this snippet work with 'content_extra' and any other Document Content Variables?

I desperately need this...

Thanks a lot in advance.

#26 Guest_Alex_*

  • Guests

Posted 18 September 2004 - 08:41 PM

I haven't really studied the Document Variables code very much. Maybe one of the creators of the modification can help you out with this ;)

#27 kartav

    Etomite Forum Newbie

  • Member
  • 10 posts

Posted 20 September 2004 - 07:05 AM

I think DCV is extremely useful Mod. Moreover it makes possible some features which are not possible before. E.g. if I need to attach an article extra attributes (little picture, big picture, price table etc.) and control these attributes through whole massive of pages (e.g. I want to create page of all prices) it seems to me I can not do it without DCV.
The only problem I have is I can not get DCV variables working in such snippets as NewsListing and NewsIndex.
I will really, really appreciate some help in it, from DCV author or other guru.
Thanks.

#28 apodigm

    Etomite Forum Newbie

  • Member
  • 41 posts

Posted 21 September 2004 - 02:07 AM

I really think that your application is unique. Regardless, it is going to require that you learn a little bit of PHP so that you can modify your snippets.

Here is a place to start. It is a modification to the Etomite API that will allow you to pull the docvars for your document.

In the root of your website, edit the file index.php, around line 725, after the following code:
function getDocument($id=0, $fields="*") {
  if($id==0) {
 	 return false;
  } else {
 	 $tmpArr[] = $id;
 	 return $this->getDocuments($tmpArr, 1, 0, $fields);
  }
	}

You need to add this API function:
function getDocVars($id=0, $fields="*") {
  if($id==0) {
 	 return false;
  } else {
 	 $tbl = $this->dbConfig['dbase'].".".$this->dbConfig['table_prefix']."docvars_values";
 	 $resourceArray = array();
      $sql = "SELECT * FROM $tbl WHERE $tbl.id=$id;";
 	 $result = $this->dbQuery($sql);
    for($i=0;$i<@$this->recordCount($result);$i++)  {
                $tmp = $this->fetchRow($result);
                if(($fields=="*")||(stristr($fields,$tmp['field_name']))){
                   $resourceArray[$tmp['field_name']] = $tmp['field_value'];
       }
            }
 	 return $resourceArray;
  }
	}


This is definitely not clean, but it should allow you to modify your snippets to call the database and retrieve the variables that you need for the document...

the function is called like this:
$etomite->getDocVars($id,'extra_content');

you can use a comma separated list for the fields that you want, or to just get all docvars, you can call like this:
$etomite->getDocVars($id);


I don't use the News* snippets that you are talking about. I suggest that you study the code a little to see how you can modify it (and other snippets) that you need.

Here is something that you could do in the NewsListing snippet for example:

etomite->getDocVars($resource[$x]['id'],'extra_content');

This basically says to get the docvar called 'extra_content' related to the page numbered by $resource[$x]['id']


Good luck.

#29 codemonkeypete

    Likes Etomite Forums!

  • Member
  • PipPip
  • 170 posts

Posted 21 September 2004 - 04:20 AM

Just wondering if Alex intends on making DCV a part of :eto: 0.7 or not?
Also, how hard would it be to make DCV a self installing add-on? ...much like phpbb modules, etc?...I have read the entire thread and agree that its not a hard thing to add to the :eto: API, but i also think that making it an installable addon would be a huge benefit to those less technical minded than some...

#30 Guest_Alex_*

  • Guests

Posted 21 September 2004 - 08:34 AM

07 will have content templates, which does pretty much the same as this mod, plus a little more. As for (installable) modules, I'm still designing a modules section, although it will probably be geared more towards collections of snippets/ chunks etc, as opposed to changing the core functionality of the system itself. Some modification of the core system should be possible, by overwriting/ appending code to source files, though.

#31 kartav

    Etomite Forum Newbie

  • Member
  • 10 posts

Posted 21 September 2004 - 01:49 PM

apodigm, on Sep 21 2004, 05:07 AM, said:

Good luck.

Thank you very much Apodigm.
I will try to use your help.

#32 Dimmy

    Etomite Forum Fan

  • Member
  • Pip
  • 109 posts

Posted 21 September 2004 - 08:25 PM

I found a small bug

when you paste some html in the Default Value: field you get this result Attached File  Gax_Export.gif   4.31K   281 downloads

I paste this piece of code to get that
<IMG src="/assets/images/logo_2.gif">


it works fine but looks a bit weard as you can see in the image

Greets Dimmy

(also implemented the Spaw editor works like a charm.)

#33 apodigm

    Etomite Forum Newbie

  • Member
  • 41 posts

Posted 21 September 2004 - 09:48 PM

hmmm...

Yeah. you might need to use htmlspecialchars to clean the raw results from the database if it has ' or " characters in it.

#34 Dimmy

    Etomite Forum Fan

  • Member
  • Pip
  • 109 posts

Posted 23 September 2004 - 08:40 PM

When making a new weblink the DCV are still ther but there is no use for them so I added this line in mutate_content.dynamic.action.php so that the DCV's are not showing in the making a weblink page.

<?php if($content['type']=="document" || $_REQUEST['a']==4) { ?>

looks like this now:

<!--//Added by Apodigm 09-06-2004- DocVars - web@apodigm.com-->

<?php if($content['type']=="document" || $_REQUEST['a']==4) { ?>
<?php
$sql2 = "select field_name, field_description, field_caption, field_type, default_text, rank, field_elements from $dbase.".$table_prefix."docvars_fields order by rank"; 
$rs2 = mysql_query($sql2); 
$limit2 = mysql_num_rows($rs2);
if($limit2>0){
?>


Greets Dimmy

[edit] Somthing whent wrong it workt but now I get a parse error:
Parse error: parse error in /var/www/html/manager/actions/dynamic/mutate_content.dynamic.action.php on line 721
line 721 is an empty line on the end of the document

So sorry I think this is not working some how.. [/edit]


#35 Guest_rthrash_*

  • Guests

Posted 06 October 2004 - 05:09 PM

Got a small bit of trouble with this one on the very last install step, for modifying the main index.php on .6 release:

Quote

9) Lastly, you need to modify the main index.php file in the root of your etomite website


Around line 576, find this code:
# this is now the document :) #
$this->documentObject = $this->fetchRow($result);

There's not much like that around line 576 that I can find... :( I certainly don't want to mung things up, so any advice would be appreciated. Getting this to work will be a tremendous stopgap measure until .7.

Thanks!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users