יחידה:PropertyLink: הבדלים בין גרסאות בדף
מראה
יצירת דף עם התוכן "local p = {} function p.property(frame) entity = mw.wikibase.getEntity() property = entity.claims[frame.args[1]] propValue = property.ma..." |
מאין תקציר עריכה |
||
| שורה 3: | שורה 3: | ||
function p.property(frame) | function p.property(frame) | ||
entity = mw.wikibase.getEntity() | entity = mw.wikibase.getEntity() | ||
if entity == nil then | |||
return "Entity not found" | |||
end | |||
property = entity.claims[frame.args[1]] | property = entity.claims[frame.args[1]] | ||
if property == nil then | |||
return "property not found" | |||
end | |||
propValue = property.mainsnak.datavalue | propValue = property.mainsnak.datavalue | ||
if propValue ==nil then | |||
return "property value not found" | |||
end | |||
if propValue['type']=='wikibase-entityid' then | if propValue['type']=='wikibase-entityid' then | ||
return '[['+mw.wikibase.sitelink(propValue.value['numeric-id'])+'|'+mw.wikibase.getLabel(propValue.value['numeric-id'])']]' | return '[['+mw.wikibase.sitelink(propValue.value['numeric-id'])+'|'+mw.wikibase.getLabel(propValue.value['numeric-id'])']]' | ||
גרסה מ־23:31, 4 באפריל 2013
יחידה זו משמשת כדי לקשר בוויקיפדיה לפי ויקינתונים. היחידה מיועדת לשימוש בעיקר בתבניות וכוללת את הפונקציות הבאות:
- property או מאפיין - לקבלת קישור לפי "קביעה" מוויקינתונים
- label או תווית: דומה לפונקציה הקודמת, רק שלא מחזיר קישור אלא ללא קישור - מחזיר את התווית (label) וללא תלות בקישור כלשהו שקיים או לא קיים בוויקיפדיה בעברית
- פרמטרים: שם המאפיין (property) המתאים (בצורה של P123)
- imageLink או תמונה: פונקציה שמחזירה תמונה שמתאימה לשילוב בתבנית מידע בערך.
- פרמטרים:
- פרמטר ראשון - (אופציונלי) אם לא מקבל פרמטר בכלל משתמש ב־d:Property:p18 (מאפיין כללי של תמונה), אחרת משתמש בפרמטר המאפיין המכיל את התמונה
- width - גודל התמונה (אחרת 220px)
- פרמטרים:
- hasEntry או יש פריט: פונקציה שמחזירה "1" אם לערך יש פריט ויקינתונים; או "" אם אין.
- פרמטרים: אין
הערות נוספות:
- ייתכן שבעתיד תהיה תמיכה מובנית לפחות בחלק מהאפשרויות הנ"ל ראו בmeta:Wikidata/Notes/Inclusion_syntax#Items
local p = {}
function p.property(frame)
entity = mw.wikibase.getEntity()
if entity == nil then
return "Entity not found"
end
property = entity.claims[frame.args[1]]
if property == nil then
return "property not found"
end
propValue = property.mainsnak.datavalue
if propValue ==nil then
return "property value not found"
end
if propValue['type']=='wikibase-entityid' then
return '[['+mw.wikibase.sitelink(propValue.value['numeric-id'])+'|'+mw.wikibase.getLabel(propValue.value['numeric-id'])']]'
elseif propValue['type']=='string' then
return propValue.value
end
end
return p