On 29.06.2015 17:16, Yaron Koren wrote: > Hi Jason, > > If you're talking about making a change to the semantic data of a page > that is not reflected in that page's wikitext, that sounds like a bad > idea - the new data would be removed as soon as the page was edited and > saved again.
Indeed, one has to be very careful here. The key is to make the change at the correct place to ensure that the data is not lost on updates or refreshs, which may not always trigger all MediaWiki hooks that you would use during normal parsing. In particular, semantic data is always secondary data which comes (mostly) from the content of the page and (in rare cases) from other metadata of the page (as for SMW's Modification date property). There are safe ways for setting properties from PHP, especially from within own parser functions. SMW's own #set parser function has examples on how to do this. Setting special properties like Modification date is more tricky. What you are trying to do sounds dangerous though, since it seems that you are trying to set the value of something that is controlled by another extension. If this is the case, you should let the other extension control it and insert into the page text whatever is necessary to get the value that you want. You cannot change SMW data to be different from what is actually given in the page -- doing so will only cause a temporary inconsistency in the database that will be "fixed" as soon as the page is stored/refreshed again. SMW data does not have an independent existence or history. It must be regenerated reliably on every refresh of the page. Regards, Markus > > -Yaron > > On Thu, Jun 25, 2015 at 3:42 PM, Jason Ji <jason.y...@gmail.com > <mailto:jason.y...@gmail.com>> wrote: > > Hi SMW community, > > I have a hopefully simple question. Is there a way to set an SMW > property for a page programmatically in PHP? Suppose I have access > to any of the relevant information, like the page ID. > > For context, I'm writing an extension which, among other things, > creates wiki pages using $wikipage->doEditContent(), and I'd like to > be able to set a semantic title > <https://www.mediawiki.org/wiki/Extension:Semantic_Title> property > on the page at that point. > > Thanks! > > -- > Jason Ji > jason.y...@gmail.com <mailto:jason.y...@gmail.com> > > > ------------------------------------------------------------------------------ > Monitor 25 network devices or servers for free with OpManager! > OpManager is web-based network management software that monitors > network devices and physical & virtual servers, alerts via email & sms > for fault. Monitor 25 devices for free with no restriction. Download now > http://ad.doubleclick.net/ddm/clk/292181274;119417398;o > _______________________________________________ > Semediawiki-devel mailing list > Semediawiki-devel@lists.sourceforge.net > <mailto:Semediawiki-devel@lists.sourceforge.net> > https://lists.sourceforge.net/lists/listinfo/semediawiki-devel > > > > > -- > WikiWorks · MediaWiki Consulting · http://wikiworks.com > > > ------------------------------------------------------------------------------ > Monitor 25 network devices or servers for free with OpManager! > OpManager is web-based network management software that monitors > network devices and physical & virtual servers, alerts via email & sms > for fault. Monitor 25 devices for free with no restriction. Download now > http://ad.doubleclick.net/ddm/clk/292181274;119417398;o > > > > _______________________________________________ > Semediawiki-devel mailing list > Semediawiki-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/semediawiki-devel > ------------------------------------------------------------------------------ Monitor 25 network devices or servers for free with OpManager! OpManager is web-based network management software that monitors network devices and physical & virtual servers, alerts via email & sms for fault. Monitor 25 devices for free with no restriction. Download now http://ad.doubleclick.net/ddm/clk/292181274;119417398;o _______________________________________________ Semediawiki-devel mailing list Semediawiki-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/semediawiki-devel