Seite 1 von 1

we_save() and filepath

Verfasst: Do 31. Mär 2016, 12:15
von ounos
I am trying to create a new document under a custom folder (i.e. my_path) using the following code:

Code: Alles auswählen

$doc = new we_webEditionDocument();
$doc->Filename = $doc_id;
$doc->Path = "/my_path/" . $doc_id . ".php";
$doc->Extension = ".php";
$doc->we_save();
but the document is created under root folder, although when I browse it, it points to http://example.com/my_path/my_doc.php.
Any ideas ?

Re: we_save() and filepath

Verfasst: Do 31. Mär 2016, 12:38
von blickfang
Hi,

try to look at an existing document by

Code: Alles auswählen

$doc = new we_webEditionDocument();
$doc->initById('yourId')
p_r($doc);
There you can find the values you have to set, like perhaps $doc->ParentID, $doc->IsSearchable and so on...

Bye
Timo

Re: we_save() and filepath

Verfasst: Do 31. Mär 2016, 13:37
von ounos
biwaMedia hat geschrieben:Hi,

try to look at an existing document by

Code: Alles auswählen

$doc = new we_webEditionDocument();
$doc->initById('yourId')
p_r($doc);
There you can find the values you have to set, like perhaps $doc->ParentID, $doc->IsSearchable and so on...

Bye
Timo
Thanks for the advice.
JFTR: setting the ParentID did the trick.

Re: we_save() and filepath

Verfasst: Do 31. Mär 2016, 13:51
von mokraemer
make sure it is really necessary you do this by plain php. It is really not recommended to use these functions/classes. In most cases there is a safe construct via our tag-api.

Re: we_save() and filepath

Verfasst: Do 31. Mär 2016, 14:50
von WBTMagnum
Thanks for the advise Marc. But since we are pulling several thousand documents from another page for a relaunch, we-Tags are not really applicable.

Cheers,
Sascha

Re: we_save() and filepath

Verfasst: Do 31. Mär 2016, 23:22
von mokraemer
ok, if this is only for "converting" some documents I don't see any problems. Adjust the statements to your needs.
Since we use the code in combination with js (our backend), some things are set via js/http-post, so you can't rely to 100% the called function sets all needed fields acordingly. As stated by Timo, check the settings of an existing document or compare the result to your basic settings, to see the difference.

For your concrete question "Path" is only informal for search - set the parentID, the path is created on save from this.