Jump to content


Snippet return document alias. How make it?


11 replies to this topic

#1 charly

    Etomite Forum Newbie

  • Member
  • 15 posts

Posted 30 August 2007 - 11:09 AM

Hello everybody.
I create snippet, wich return document's ID.

$output  = 'http://www.udec.com.ua/ru/index.php?id=' . $etomite->documentIdentifier . '';

return $output;


Now I need snippet, which return document's alias. How make it?

Thanks in advance.

#2 Cris D.

    Loves Etomite Forums!

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

Posted 30 August 2007 - 12:30 PM

See the documentation...

Quote

getPageInfo($id=-1, $active=1, $fields='id, pagetitle, description, alias')

// returns a $key=>$value array of information for a single document
// $id is the identifier of the document whose data is being requested
// $active boolean (0=false|1=true) determines whether to return data for any or only an active document
// $fields is a comma delimited list of fields to be returned in a $key=>$value array


#3 charly

    Etomite Forum Newbie

  • Member
  • 15 posts

Posted 30 August 2007 - 12:32 PM

I read the documentation, but and have not understood how to realize it. I tried - nothing has turned out

#4 Cris D.

    Loves Etomite Forums!

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

Posted 30 August 2007 - 12:54 PM

$id=1;//doc to get alias from
$docAlias=$etomite->getPageInfo($id, $active=1, $fields='alias');

return $docAlias['alias'];

Have a read of these tutorials.
for some basic coding in etomite. :)

#5 charly

    Etomite Forum Newbie

  • Member
  • 15 posts

Posted 30 August 2007 - 01:03 PM

This code for page id=1.
How to make this for current page?

#6 Cris D.

    Loves Etomite Forums!

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

Posted 30 August 2007 - 01:17 PM

View Postcharly, on Aug 30 2007, 11:03 PM, said:

This code for page id=1.
How to make this for current page?
You just wrote that snippet!

Quote

Hello everybody.
I create snippet, wich return document's ID.

$output  = 'http://www.udec.com.ua/ru/index.php?id=' . $etomite->documentIdentifier . '';

return $output;


#7 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 30 August 2007 - 01:21 PM

I had an IM here from charly when I sat down at my desk... I advised him to use $etomite->documentObject['alias'] and that seems to have been what he was looking for...

#8 Jim Browski

    Likes Etomite Forums!

  • Member
  • PipPip
  • 163 posts

Posted 19 September 2007 - 09:54 AM

View PostRalph, on Aug 30 2007, 03:21 PM, said:

I had an IM here from charly when I sat down at my desk... I advised him to use $etomite->documentObject['alias'] and that seems to have been what he was looking for...
Ups, i didn't mention before that this function "$etomite->documentObject['alias']" even exists!
For me it would have been very useful in former snippet development if i knew it were available.

Shouldn't we make a new, complete list of all functions with even a rudimentary documentation?
The existing "documentation" seems way to old and incomplete.

#9 Cris D.

    Loves Etomite Forums!

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

Posted 19 September 2007 - 10:42 AM

All the most of APIs and the objects from the $etomite->class can be found in the index.php file. Also, I have recently written a snippet etoInfo that allows you to see the results of each $etomite->variable. If it says 'Array', then there is a few fields that you can draw on and you might like to put in a call to it specifically see what it contains.

If you think we need more documentation (I agree with you there) there is an open invitation for anyone who wants to create it.

#10 Dean

    Loves Etomite Forums!

  • Admin
  • 4,758 posts
  • Gender:Male

Posted 19 September 2007 - 10:55 AM

Whereas I would have done this:

$output  = '[~' . $etomite->documentIdentifier . '~]';

return $output;


It would return ether the id number of the page, the id number of the page + the extension, or the alias (+ext), depending on the etomite configuration.

#11 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 19 September 2007 - 01:09 PM

View PostDean, on Sep 19 2007, 06:55 AM, said:

Whereas I would have done this:

$output  = '[~' . $etomite->documentIdentifier . '~]';

return $output;
It would return ether the id number of the page, the id number of the page + the extension, or the alias (+ext), depending on the etomite configuration.
I agree with that, Dean... Had I known exactly what the code was supposed to do I would have suggested that, and it's quite possible that I did somewhere along the way... However, just the other night I had a problem with the code you mentioned returning a Friendly Alias... But, now that I think about it, performing a Clear site cache may have resolved the issue... It took me by surprise that it didn't work as expected and I switched to using makeUrl() instead of doing any further investigation...

#12 Dean

    Loves Etomite Forums!

  • Admin
  • 4,758 posts
  • Gender:Male

Posted 19 September 2007 - 01:14 PM

Thats the great thing about etomite - you can do things lots of different ways; mine is the non-PHP'ers way, whereas Ralph likes to do things proper!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users