On 13/05/2020 09:41, Benjamin Grassineau wrote:
Just a very basic question. I don't understand. $pn is a "default
argument" of PageVar function ?

The code defined for $FmtPV is in quotes, because it will be evaluated in PageVar(). When that happens, there are a few variables that are available directly in your code: $pagename, $pn, $group, $name, $page.

$pagename is the page currently requested for browsing, and $pn is either the same, or some remote page where you need to get the $Title, or some $:PTV. $page is the full page metadata (text, author, dates, ip address, etc.). Here I'll use $pn because I'll have to get information from different pages.

In our case, when a variable {$TitreArticle} is requested, it will be evaluated inside PageVar() and that code will call once again PageVar() but with a different argument, for the page text variable.

Now that I think of it, it can be optimized to directly call PageTextVar:

  $FmtPV['$TitreArticle'] = 'PageTextVar($pn, "TitreArticle")';

This should be slightly faster than my first line but not noticeably -- maybe a few microseconds. I'm sure the time I spent writing this change you reading it will only be saved in several hundred years. ;-)

Petko


On 12/05/2020 17:15, Petko Yotov wrote:
Sorry for the late reply.

This should work, where {$:TitreArticle} is your PTV :

  $FmtPV['$TitreArticle'] = 'PageVar($pn, "$:TitreArticle")';
  $FeedFmt['rss']['item']['title'] = '{$TitreArticle}';

You don't need to use ResolvePageName() like you wrote in the French mailing list, in fact you should probably remove it.

Petko


On 12/05/2020 13:48, Benjamin Grassineau wrote:
Hello everybody !

Do you think it is possible to insert a page text variable in a RSS
feed ?

 I saw that it is possible with page variables, like this :

$FeedFmt['rss']['item']['title'] = '{$Title}';

But I would like to have something like that :

$FeedFmt['rss']['item']['title'] = '{$:var}';

So I tried to create a php variable with this :

$var=PageVar($pagename [1],'$:var')

But this code doesn't work.

$FeedFmt['rss']['item']['title'] = '{$var}';

Nothing in "output feed" (sorry for my awful english !).

Someone have an idea ?

_______________________________________________
pmwiki-users mailing list
[email protected]
http://www.pmichaud.com/mailman/listinfo/pmwiki-users

Reply via email to