अपने लॉयल्टी पास को पसंद के मुताबिक बनाने के लिए नीचे दिए गए टूल का इस्तेमाल करें और नीचे दिए गए कोड स्निपेट देखें.
लॉयल्टी पास के लिए, टेंप्लेट रेंडरिंग की सुविधा काम करती है. अगर कोई टेंप्लेट तय नहीं किया गया है, तो डिफ़ॉल्ट टेंप्लेट का इस्तेमाल किया जाता है.
टेंप्लेट की परिभाषा
पास टेंप्लेट को क्लास लेवल पर बताया जाता है और इसका इस्तेमाल कक्षा से जुड़े किसी भी ऑब्जेक्ट को दिखाने के लिए किया जाता है. टेंप्लेट में यह बताया जाता है कि पास के अलग-अलग सेक्शन में कौनसे फ़ील्ड दिखाने हैं.
टेंप्लेट को इन सेक्शन में बांटा गया है:
Android
वेब
कार्ड शीर्षक
Android
|
|
वेब
|
|
कार्ड के शीर्षक वाले सेक्शन में लोगो, कार्ड जारी करने वाले का नाम, और कार्यक्रम का शीर्षक दिखता है. फ़ील्ड में दी गई जानकारी का इस्तेमाल, अपने-आप जानकारी भरने के लिए न किया जा सकता है और न ही उनकी जगह बदली जा सकती है.
कार्ड का टेंप्लेट
Android

वेब

कार्ड के टेंप्लेट वाले सेक्शन का इस्तेमाल, अतिरिक्त पंक्तियां दिखाने के लिए किया जाता है. इन पंक्तियों में टेक्स्ट पर आधारित स्ट्रक्चर्ड डेटा फ़ील्ड या टेक्स्ट मॉड्यूल फ़ील्ड हो सकते हैं.
पंक्तियों की संख्या बताएं, जो class.classTemplateInfo.cardTemplateOverride.cardRowTemplateInfos[]
सूची में ऑब्जेक्ट की संख्या बताती है. इस सूची में कम से कम एक एलिमेंट होना ज़रूरी है. हालांकि, हमने
ज़्यादा से ज़्यादा दो एलिमेंट का इस्तेमाल करने का सुझाव दिया है. हर एलिमेंट, इनमें से किसी एक टाइप का होना चाहिए:
-
oneItem
, इनमें से एक आइटम स्वीकार करता है:item
-
twoItems
, दो आइटम स्वीकार करता है:startItem
endItem
-
threeItems
, तीन आइटम स्वीकार करता है:startItem
middleItem
endItem
हर आइटम को एक फ़ील्ड सिलेक्टर (.firstValue
), दो फ़ील्ड सिलेक्टर (.firstValue
और .secondValue
) या पहले से तय किया गया आइटम (.predefinedItem
) तय किया जा सकता है. चुने गए फ़ील्ड की वैल्यू और उनसे जुड़े लेबल, दोनों दिखते हैं. जब दो फ़ील्ड सिलेक्टर तय किए जाते हैं, तो चुने गए फ़ील्ड की वैल्यू "/" सेपरेटर के साथ दिखती है. यही
चुने गए फ़ील्ड के लेबल पर भी लागू होता है. पहले से तय आइटम का इस्तेमाल, ज़्यादा रेंडर करने के लिए किया जाता है.
कोड के इस नमूने में, कार्ड के टेंप्लेट के कार्ड की पंक्ति को बदलने का तरीका
बताया गया है, ताकि दो पंक्तियों की जानकारी दी जा सके. हर लाइन में तीन ऐसे आइटम होते हैं जिनमें से हर छह में, छह क्लास के लेवल के textModuleData
कस्टम फ़ील्ड और उनके हेडर, लेबल के तौर पर शामिल होते हैं:
Python
{ ... //Rest of class "textModulesData": [ { "header": "Label 1", "body": "Some info 1", "id": "myfield1" }, { "header": "Label 2", "body": "Some info 2", "id": "myfield2" }, { "header": "Label 3", "body": "Some info 3", "id": "myfield3" }, { "header": "Label 4", "body": "Some info 4", "id": "myfield4" }, { "header": "Label 5", "body": "Some info 5", "id": "myfield5" }, { "header": "Label 6", "body": "Some info 6", "id": "myfield6" } ], "classTemplateInfo": { "cardTemplateOverride": { "cardRowTemplateInfos": [{ "threeItems": { "startItem": { "firstValue": { "fields": [{ "fieldPath": "class.textModulesData['myfield1']" }] } }, "middleItem": { "firstValue": { "fields": [{ "fieldPath": "class.textModulesData['myfield2']" }] } }, "endItem": { "firstValue": { "fields": [{ "fieldPath": "class.textModulesData['myfield3']" }] } }, } },{ "threeItems": { "startItem": { "firstValue": { "fields": [{ "fieldPath": "class.textModulesData['myfield4']" }] } }, "middleItem": { "firstValue": { "fields": [{ "fieldPath": "class.textModulesData['myfield5']" }] } }, "endItem": { "firstValue": { "fields": [{ "fieldPath": "class.textModulesData['myfield6']" }] } }, } }] } } }
Java
// Rest of class .setTextModulesData((new ArrayList<TextModuleData>() { { add((new TextModuleData()).setHeader("Label 1") .setBody("Some info 1") .setId("myfield1")); add((new TextModuleData()).setHeader("Label 2") .setBody("Some info 1") .setId("myfield2")); add((new TextModuleData()).setHeader("Label 3") .setBody("Some info 3") .setId("myfield3")); add((new TextModuleData()).setHeader("Label 4") .setBody("Some info 4") .setId("myfield4")); add((new TextModuleData()).setHeader("Label 5") .setBody("Some info 5") .setId("myfield5")); add((new TextModuleData()).setHeader("Label 6") .setBody("Some info 5") .setId("myfield6")); } })) .setClassTemplateInfo((new ClassTemplateInfo()) .setCardTemplateOverride((new CardTemplateOverride()) .setCardRowTemplateInfos(new ArrayList<CardRowTemplateInfo>() { { add((new CardRowTemplateInfo()).setThreeItems((new CardRowThreeItems()) .setStartItem((new TemplateItem()).setFirstValue((new FieldSelector()).setFields(new ArrayList<FieldReference>(){ { add((new FieldReference()).setFieldPath("class.textModulesData['myfield1']")); } }))) .setMiddleItem((new TemplateItem()).setFirstValue((new FieldSelector()).setFields(new ArrayList<FieldReference>(){ { add((new FieldReference()).setFieldPath("class.textModulesData['myfield2']")); } }))) .setEndItem((new TemplateItem()).setFirstValue((new FieldSelector()).setFields(new ArrayList<FieldReference>(){ { add((new FieldReference()).setFieldPath("class.textModulesData['myfield3']")); } }))) )); add((new CardRowTemplateInfo()).setThreeItems((new CardRowThreeItems()) .setStartItem((new TemplateItem()).setFirstValue((new FieldSelector()).setFields(new ArrayList<FieldReference>(){ { add((new FieldReference()).setFieldPath("class.textModulesData['myfield4']")); } }))) .setMiddleItem((new TemplateItem()).setFirstValue((new FieldSelector()).setFields(new ArrayList<FieldReference>(){ { add((new FieldReference()).setFieldPath("class.textModulesData['myfield5']")); } }))) .setEndItem((new TemplateItem()).setFirstValue((new FieldSelector()).setFields(new ArrayList<FieldReference>(){ { add((new FieldReference()).setFieldPath("class.textModulesData['myfield6']")); } }))) )); } })))
PHP
// Rest of class $textModulesData1 = new Google_Service_Walletobjects_TextModuleData(); $textModulesData1->setBody("Some info 1"); $textModulesData1->setHeader("Label 1"); $textModulesData1->setId("myfield1"); $textModulesData2 = new Google_Service_Walletobjects_TextModuleData(); $textModulesData2->setBody("Some info 2"); $textModulesData2->setHeader("Label 2"); $textModulesData2->setId("myfield2"); $textModulesData3 = new Google_Service_Walletobjects_TextModuleData(); $textModulesData3->setBody("Some info 3"); $textModulesData3->setHeader("Label 3"); $textModulesData3->setId("myfield3"); $textModulesData4 = new Google_Service_Walletobjects_TextModuleData(); $textModulesData4->setBody("Some info 4"); $textModulesData4->setHeader("Label 4"); $textModulesData4->setId("myfield4"); $textModulesData5 = new Google_Service_Walletobjects_TextModuleData(); $textModulesData5->setBody("Some info 5"); $textModulesData5->setHeader("Label 5"); $textModulesData5->setId("myfield5"); $textModulesData6 = new Google_Service_Walletobjects_TextModuleData(); $textModulesData6->setBody("Some info 6"); $textModulesData6->setHeader("Label 6"); $textModulesData6->setId("myfield6"); $textModulesDatas = array($textModulesData1, $textModulesData2, $textModulesData3, $textModulesData4, $textModulesData5, $textModulesData6); $startItemField = new Google_Service_Walletobjects_FieldReference(); $startItemField->setFieldPath("class.textModulesData['myfield1']"); $startItemFirstValue = new Google_Service_Walletobjects_FieldSelector(); $startItemFirstValue->setFields(array($startItemField)); $startItem = new Google_Service_Walletobjects_TemplateItem(); $startItem->setFirstValue($startItemFirstValue); $middleItemField = new Google_Service_Walletobjects_FieldReference(); $middleItemField->setFieldPath("class.textModulesData['myfield2']"); $middleItemFirstValue = new Google_Service_Walletobjects_FieldSelector(); $middleItemFirstValue->setFields(array($middleItemField)); $middleItem = new Google_Service_Walletobjects_TemplateItem(); $middleItem->setFirstValue($middleItemFirstValue); $endItemField = new Google_Service_Walletobjects_FieldReference(); $endItemField->setFieldPath("class.textModulesData['myfield3']"); $endItemFirstValue = new Google_Service_Walletobjects_FieldSelector(); $endItemFirstValue->setFields(array($endItemField)); $endItem = new Google_Service_Walletobjects_TemplateItem(); $endItem->setFirstValue($endItemFirstValue); $cardRowTemplate = new Google_Service_Walletobjects_CardRowThreeItems(); $cardRowTemplate->setStartItem($startItem); $cardRowTemplate->setMiddleItem($middleItem); $cardRowTemplate->setEndItem($endItem); $cardRowTemplateInfo1 = new Google_Service_Walletobjects_CardRowTemplateInfo(); $cardRowTemplateInfo1->setThreeItems($cardRowTemplate); $startItemField2 = new Google_Service_Walletobjects_FieldReference(); $startItemField2->setFieldPath("class.textModulesData['myfield4']"); $startItemFirstValue2 = new Google_Service_Walletobjects_FieldSelector(); $startItemFirstValue2->setFields(array($startItemField2)); $startItem2 = new Google_Service_Walletobjects_TemplateItem(); $startItem2->setFirstValue($startItemFirstValue2); $middleItemField2 = new Google_Service_Walletobjects_FieldReference(); $middleItemField2->setFieldPath("class.textModulesData['myfield5']"); $middleItemFirstValue2 = new Google_Service_Walletobjects_FieldSelector(); $middleItemFirstValue2->setFields(array($middleItemField2)); $middleItem2 = new Google_Service_Walletobjects_TemplateItem(); $middleItem2->setFirstValue($middleItemFirstValue2); $endItemField2 = new Google_Service_Walletobjects_FieldReference(); $endItemField2->setFieldPath("class.textModulesData['myfield6']"); $endItemFirstValue2 = new Google_Service_Walletobjects_FieldSelector(); $endItemFirstValue2->setFields(array($endItemField2)); $endItem2 = new Google_Service_Walletobjects_TemplateItem(); $endItem2->setFirstValue($endItemFirstValue2); $cardRowTemplate2 = new Google_Service_Walletobjects_CardRowThreeItems(); $cardRowTemplate2->setStartItem($startItem2); $cardRowTemplate2->setMiddleItem($middleItem2); $cardRowTemplate2->setEndItem($endItem2); $cardRowTemplateInfo2 = new Google_Service_Walletobjects_CardRowTemplateInfo(); $cardRowTemplateInfo2->setThreeItems($cardRowTemplate2); $cardTemplateOverride = new Google_Service_Walletobjects_CardTemplateOverride(); $cardTemplateOverride->setCardRowTemplateInfos(array($cardRowTemplateInfo1, $cardRowTemplateInfo2)); $classTemplateInfo = new Google_Service_Walletobjects_ClassTemplateInfo(); $classTemplateInfo->setCardTemplateOverride($cardTemplateOverride); $payload->setTextModulesData($textModulesDatas); $payload->setClassTemplateInfo($classTemplateInfo);
इस कोड में, कोड टेंप्लेट के इस फ़ॉर्मैट वाला पास होता है:

अगर कोई आइटम खाली है, तो उसे नहीं दिखाया जाता है. ज़्यादा जानकारी के लिए, फ़ील्ड रेफ़रंस देखें. अगर एक पंक्ति में सभी आइटम खाली हैं, तो पंक्ति नहीं दिखेगी. अगर पंक्ति में मौजूद सभी आइटम खाली हैं, तो सभी आइटम खाली होते हैं. ऐसे आइटम फिर से व्यवस्थित किए जाते हैं और उन्हें कम आइटम वाली पंक्ति के तौर पर दिखाया जाता है.
अगर आप कार्ड के टेंप्लेट को नहीं बदलते हैं, तो पंक्तियों की डिफ़ॉल्ट संख्या, आइटम की डिफ़ॉल्ट संख्या, और डिफ़ॉल्ट फ़ील्ड के रेफ़रंस इस्तेमाल किए जाते हैं. ज़्यादा जानकारी के लिए, डिफ़ॉल्ट टेंप्लेट देखें.
हीरो इमेज तय करने के बाद, अगर पहली सूची के बाद cardRowTemplateInfos
की सूची में एक से ज़्यादा पंक्तियां हैं, तो उसे पहली पंक्ति के बाद
कार्ड बारकोड
Android
|
|
वेब
|
|
कार्ड के बारकोड वाले सेक्शन का इस्तेमाल, बारकोड के ऊपर और नीचे अतिरिक्त टेक्स्ट या इमेज दिखाने के लिए किया जाता है. इस सेक्शन के किसी भी फ़ील्ड की ज़रूरत नहीं होती है.
फ़ील्ड सिलेक्टर तीन होते हैं, जिन्हें ऊपर और साथ में दो फ़ील्ड को तय करने के लिए इस्तेमाल किया जा सकता है. इन्हें बिना किसी लेबल के दिखाया जाता है. साथ ही, ये टेक्स्ट-आधारित स्ट्रक्चर्ड डेटा फ़ील्ड, टेक्स्ट मॉड्यूल फ़ील्ड या इमेज मॉड्यूल फ़ील्ड हो सकते हैं. इमेज का इस्तेमाल करने से पहले, ब्रैंड के दिशा-निर्देशों का पालन करना ज़रूरी है.
बारकोड, टाइप और वैल्यू से तय किया जाता है. इस्तेमाल किए जा सकने वाले बारकोड के टाइप की सूची देखने के लिए, पहचान फ़ाइल देखें. इसके अलावा, बारकोड के ठीक नीचे एक टेक्स्ट दिखाया जा सकता है. इस टेक्स्ट से, बारकोड को आसानी से स्कैन किया जा सकता है. ऐसे ही कई इस्तेमाल हैं.
कोड के इस उदाहरण में बताया गया है कि बारकोड के ऊपर की इमेज दिखाने के लिए, पास के बारकोड सेक्शन को कैसे बदला जाता है:
Python
#... rest of class "imageModulesData": [ { "mainImage": { "sourceUri": { "uri": "http://farm4.staticflickr.com/3738/12440799783_3dc3c20606_b.jpg", "description": "Coffee" } }, "Id": "myimage" } ], "classTemplateInfo": { "cardBarcodeSectionDetails": { "firstTopDetail": { "fieldSelector": { "fields": [ { "fieldPath": "class.imageModulesData['myimage'].mainImage" } ] } } } } }
Java
//... rest of class .setImageModulesData((new ArrayList<ImageModuleData>() { { add((new ImageModuleData()) .setId("myimage") .setMainImage((new Image()).setSourceUri((new ImageUri()).setDescription("Coffee beans") .setUri("http://farm4.staticflickr.com/3738/12440799783_3dc3c20606_b.jpg")))); } })) .setClassTemplateInfo((new ClassTemplateInfo()) .setCardBarcodeSectionDetails((new CardBarcodeSectionDetails()) .setFirstTopDetail((new BarcodeSectionDetail()) .setFieldSelector((new FieldSelector()) .setFields((new ArrayList<FieldReference>(){ { add((new FieldReference()).setFieldPath("class.imageModulesData['myimage'].mainImage")); } }))))) }
PHP
//... rest of class $imageUri = new Google_Service_Walletobjects_ImageUri(); $imageUri->setUri("https://farm8.staticflickr.com/7340/11177041185_a61a7f2139_o.jpg"); $imageUri->setDescription("Baconrista flights image"); $image = new Google_Service_Walletobjects_Image(); $image->setSourceUri($imageUri); $imageModulesData = new Google_Service_Walletobjects_ImageModuleData(); $imageModulesData->setMainImage($image); $imageModulesData->setId("myimage"); $cardBarcodeFieldReference = new Google_Service_Walletobjects_FieldReference(); $cardBarcodeFieldReference->setFieldPath("class.imageModulesData['myimage'].mainImage"); $cardBarcodeFieldSelector = new Google_Service_Walletobjects_FieldSelector(); $cardBarcodeFieldSelector->setFields(array($cardBarcodeFieldReference)); $cardBarcodeDetail = new Google_Service_Walletobjects_BarcodeSectionDetail(); $cardBarcodeDetail->setFieldSelector($cardBarcodeFieldSelector); $cardBarcodeSectionDetails = new Google_Service_Walletobjects_CardBarcodeSectionDetails(); $cardBarcodeSectionDetails->setFirstTopDetail($cardBarcodeDetail); $classTemplateInfo = new Google_Service_Walletobjects_ClassTemplateInfo(); $classTemplateInfo->setCardBarcodeSectionDetails($cardBarcodeSectionDetails); $payload->setClassTemplateInfo($classTemplateInfo); $payload->setImageModuleData($imageModulesData);
यह कोड, यहां दिए गए बारकोड सेक्शन फ़ॉर्मैट का इस्तेमाल करके पास बनाता है:

अगर आप बारकोड सेक्शन को नहीं बदलते हैं, तो डिफ़ॉल्ट बारकोड फ़ील्ड का इस्तेमाल किया जाता है. ज़्यादा जानकारी के लिए, डिफ़ॉल्ट टेंप्लेट देखें.
जानकारी वाला टेंप्लेट
Android
|
|
वेब
|
|
जानकारी वाले टेंप्लेट का सेक्शन, class.classTemplateInfo.detailsTemplateOverride.detailsItemInfos[]
आइटम की सूची है. आइटम में किसी भी तरह का स्ट्रक्चर्ड डेटा फ़ील्ड, टेक्स्ट मॉड्यूल फ़ील्ड, लिंक मॉड्यूल फ़ील्ड, इमेज मॉड्यूल फ़ील्ड या मैसेज शामिल हो सकते हैं.
हर आइटम को एक फ़ील्ड सिलेक्टर (.firstValue
), दो फ़ील्ड सिलेक्टर (.firstValue
और .secondValue
) या पहले से तय आइटम (.predefinedItem
) के तौर पर बताया जा सकता है. चुने गए फ़ील्ड की वैल्यू और उनसे जुड़े लेबल, दोनों दिखते हैं. जब दो फ़ील्ड सिलेक्टर तय किए जाते हैं, तो चुने गए फ़ील्ड की वैल्यू "/" सेपरेटर के साथ दिखती है. यही बात चुने गए फ़ील्ड के लेबल पर भी लागू होती है. पहले से तय आइटम का इस्तेमाल, ज़्यादा जटिल रेंडरिंग तय करने के लिए किया जाता है. इमेज मॉड्यूल फ़ील्ड को बिना लेबल के, पूरी चौड़ाई में रेंडर किया जाता है.
कोड का यह सैंपल दिखाता है कि पास की जानकारी वाले सेक्शन को कैसे बदला जा सकता है, ताकि इसमें linksModuleData
फ़ील्ड को उसके लेबल के साथ दिखाया जा सके:
Python
//... rest of class "linksModuleData": { "uris": [ { "uri": "http://maps.google.com/", "description": "Nearby Locations", "id":"mylink" } ] }, "classTemplateInfo": { "detailsTemplateOverride": { "detailsItemInfos": [ { "item":{ "firstValue": { "fields": [{ "fieldPath": "class.linksModuleData.uris['mylink']" }] } } } ] } } //... rest of class
Java
//... rest of class .setLinksModuleData((new ArrayList<LinksModuleData>() { { add((new LinksModuleData()).setDescription("Nearby Locations") .setUri("http://maps.google.com/") .setId("mylink")); })) .setClassTemplateInfo((new ClassTemplateInfo()) .setDetailsTemplateOverride((new DetailsTemplateOverride()) .setDetailsItemInfos(new ArrayList<DetailsItemInfo>(){ { add((new DetailsItemInfo()) .setItem((new TemplateItem()).setFirstValue((new FieldSelector()).setFields(new ArrayList<FieldReference>(){ { add((new FieldReference()).setFieldPath("class.linksModuleData.uris['mylink']")); } })))); } })) //... rest of class
PHP
//... rest of class building $locationUri = new Google_Service_Walletobjects_Uri(); $locationUri->setUri("http://maps.google.com/"); $locationUri->setDescription("Nearby Locations"); $locationUri->setId("mylink"); $linksModuleData = new Google_Service_Walletobjects_LinksModuleData(); $linksModuleData->setUris(array($locationUri)); $detailItemFieldReference = new Google_Service_Walletobjects_FieldReference(); $detailItemFieldReference->setFieldPath("class.linksModuleData.uris['mylink']"); $detailItemFieldSelector = new Google_Service_Walletobjects_FieldSelector(); $detailItemFieldSelector->setFields(array($detailItemFieldReference)); $detailItem = new Google_Service_Walletobjects_TemplateItem(); $detailItem->setFirstValue($detailItemFieldSelector); $detailsItemInfo = new Google_Service_Walletobjects_DetailsItemInfo(); $detailsItemInfo->setItem($detailItem); $cardDetailsTemplateOverride = new Google_Service_Walletobjects_DetailsTemplateOverride(); $cardDetailsTemplateOverride->setDetailsItemInfos(array($detailsItemInfo)); $classTemplateInfo = new Google_Service_Walletobjects_ClassTemplateInfo(); $classTemplateInfo->setDetailsTemplateOverride($cardDetailsTemplateOverride); $payload->setClassTemplateInfo($classTemplateInfo); $payload->setLinksModuleData($linksModuleData); //... rest of class
यह कोड यहां दी गई जानकारी वाले सेक्शन में एक पास बनाता है:

अगर कोई आइटम खाली है, तो उसे नहीं दिखाया जाता है. ज़्यादा जानकारी के लिए, फ़ील्ड रेफ़रंस देखें.
जानकारी वाले टेंप्लेट को न बदलने पर, डिफ़ॉल्ट क्रम में रेफ़रंस फ़ील्ड की डिफ़ॉल्ट सूची दिखेगी. ज़्यादा जानकारी के लिए, डिफ़ॉल्ट टेंप्लेट देखें.
सूची टेंप्लेट
|
|
सूची के टेंप्लेट के सेक्शन का इस्तेमाल, यह चुनने के लिए किया जाता है कि Google Wallet ऐप्लिकेशन के "पास" व्यू में कौनसा फ़ील्ड दिखाया जाए. पास को सूची में लोगो, बैकग्राउंड के रंग, और तीन पंक्तियों के साथ दिखाया जाता है.
कोड का यह सैंपल, पास की सूची के टेंप्लेट को बदलने का तरीका बताता है. यह टेंप्लेट, सूची के टेंप्लेट की पहली पंक्ति में, किसी एक पास की ऑब्जेक्ट की समयसीमा खत्म होने की तारीख वाला फ़ील्ड दिखाने का तरीका है:
Python
#... rest of class definition "classTemplateInfo": { "listTemplateOverride":{ "firstRowOption": { "fieldOption":{ "fields": [{ "fieldPath": "object.validTimeInterval.end" }] } } } } }
Java
//... rest of class .setClassTemplateInfo((new ClassTemplateInfo()) .setListTemplateOverride((new ListTemplateOverride()) .setFirstRowOption((new FirstRowOption()) .setFieldOption((new FieldSelector()).setFields(new ArrayList<FieldReference>(){ { add((new FieldReference()).setFieldPath("object.validTimeInterval.end")); } })))) //... rest of class
PHP
//... rest of class $fieldReference = new Google_Service_Walletobjects_FieldReference(); $fieldReference->setFieldPath("object.validTimeInterval.end"); $fieldOption = new Google_Service_Walletobjects_FieldSelector(); $fieldOption->setFields(array($fieldReference)); $firstRowOption = new Google_Service_Walletobjects_FirstRowOption(); $firstRowOption->setFieldOption($fieldOption); $listTemplateOverride = new Google_Service_Walletobjects_ListTemplateOverride(); $listTemplateOverride->setFirstRowOption($firstRowOption); $classTemplateInfo = new Google_Service_Walletobjects_ClassTemplateInfo(); $classTemplateInfo->setListTemplateOverride($listTemplateOverride); $payload->setClassTemplateInfo($classTemplateInfo); //... rest of class
यह कोड इस सूची टेंप्लेट के साथ एक पास बनाता है:

तीन पंक्तियों को फ़ील्ड चुनने वाले की मदद से तय किया जा सकता है. फ़ील्ड को बिना किसी लेबल के दिखाया जाता है.
लेबल
सभी स्ट्रक्चर्ड डेटा फ़ील्ड में, Google से मिला लेबल होता है. इन लेबल में इस्तेमाल होने वाली सभी भाषाओं का अनुवाद उपलब्ध कराने की ज़िम्मेदारी Google की होती है.
इनमें से किसी लेबल को अपनी पसंद के मुताबिक बनाया जा सकता है. इसके लिए, class.custom<name_of_the_field>Label
फ़ील्ड में से किसी एक का इस्तेमाल करें. जब आप किसी लेबल को पसंद के मुताबिक बनाते हैं, तो उस भाषा के लिए उन सभी भाषाओं में अनुवाद उपलब्ध कराने की ज़िम्मेदारी आपकी होती है जिनमें आपको अनुवाद करना है.
फ़ील्ड के बारे में जानकारी
फ़ील्ड रेफ़रंस को टेंप्लेट के अलग-अलग हिस्सों में, class.classTemplateInfo.*.fields[]
फ़ॉर्म के साथ इस्तेमाल किया जाता है. फ़ील्ड रेफ़रंस में स्ट्रक्चर्ड डेटा फ़ील्ड, टेक्स्ट मॉड्यूल फ़ील्ड, लिंक मॉड्यूल फ़ील्ड, इमेज मॉड्यूल फ़ील्ड या मैसेज के पाथ की सूची शामिल होती है.
हर फ़ील्ड रेफ़रंस में, सभी तरह के पाथ की अनुमति नहीं होती है. उदाहरण के लिए, कुछ फ़ील्ड रेफ़रंस सिर्फ़ टेक्स्ट पर आधारित स्ट्रक्चर्ड डेटा फ़ील्ड या टेक्स्ट मॉड्यूल फ़ील्ड के पाथ की अनुमति देते हैं. टेक्स्ट पर आधारित स्ट्रक्चर्ड फ़ील्ड, टाइप स्ट्रिंग, स्थानीय भाषा वाली स्ट्रिंग, तारीख या पैसों वाले स्ट्रक्चर्ड डेटा फ़ील्ड होते हैं.
इस सूची का इस्तेमाल, फ़ॉलबैक लॉजिक को लागू करने के लिए किया जा सकता है. इसका मतलब है कि अगर सूची का पहला पाथ किसी खाली फ़ील्ड में आता है, तो अगले पाथ का आकलन किया जाता है. फ़ॉलबैक लॉजिक मुख्य रूप से टेक्स्ट पर आधारित स्ट्रक्चर्ड डेटा फ़ील्ड या टेक्स्ट मॉड्यूल फ़ील्ड पर टारगेट किया जाता है. एक ही सूची में अलग-अलग तरह के फ़ील्ड न मिलाएं. फ़ॉलबैक लॉजिक का इस्तेमाल सावधानी से करें और सिर्फ़ तब कुछ खास स्थितियों में करें, जब आपको किसी फ़ील्ड में एक जैसे पैटर्न का इस्तेमाल हो रहा हो, जो सिर्फ़ कुछ ऑब्जेक्ट में मौजूद हो. ज़्यादातर मामलों में, इस्तेमाल के अलग-अलग मामलों के लिए अलग-अलग क्लास बनाना आसान होता है.
अगर फ़ील्ड की रेफ़रंस सूची में मौजूद सभी पाथ खाली फ़ील्ड में जाते हैं, तो फ़ील्ड रेफ़रंस का इस्तेमाल करने वाले आइटम को नहीं दिखाया जाता है. अगर आपको फ़ील्ड के रेफ़रंस का इस्तेमाल करने वाले आइटम को हमेशा मौजूद रखना है, तो पक्का करें कि कम से कम एक पाथ खाली न हो. हमारा सुझाव है कि आप शून्य-वैल्यू दिखाने के लिए, फ़ील्ड को किसी खास वर्ण, जैसे कि ‘-’ पर सेट करें. भले ही, कुछ फ़ील्ड में सिर्फ़ स्पेस वाली स्ट्रिंग की अनुमति हो.
किसी सूची में शामिल फ़ील्ड का रेफ़रंस देने के लिए, आप सूची में मौजूद फ़ील्ड के इंडेक्स का इस्तेमाल कर सकते हैं. ज़्यादातर मामलों में, आप रेफ़रंस आईडी का इस्तेमाल भी कर सकते हैं. सूची में मौजूद ऐसे आइटम जिनके बारे में आईडी से बताया जा सकता है, उनके पास .id
फ़ील्ड होता है. हमारा सुझाव है कि आप सूची में फ़ील्ड के इंडेक्स के बजाय, रेफ़रंस आईडी का इस्तेमाल करें.
यहां एक सूची में दिए गए फ़ील्ड को रेफ़र करने का उदाहरण दिया गया है.
object.imageModulesData[0].id = my-first-id
object.imageModulesData[1].id = my-second-id
class.detailsTemplateOverride.detailsItemInfos[0].item.firstValue.fields[0].fieldPath = object.imageModulesData[‘my-second-id’]
class.detailsTemplateOverride.detailsItemInfos[1].item.firstValue.fields[0].fieldPath = object.imageModulesData[0]
ऐसे मामले में, पास की जानकारी वाले सेक्शन में पहला आइटम, ऑब्जेक्ट में बताया गया दूसरा होता है. हालांकि, पास के ब्यौरे वाले सेक्शन में दूसरा आइटम, ऑब्जेक्ट में बताया गया पहला इमेज होता है.
डिफ़ॉल्ट टेंप्लेट
Android
|
|
वेब
|
|
इमेज मॉड्यूल फ़ील्ड के लिए, हम क्लास से एक और सिर्फ़ एक इमेज मॉड्यूल फ़ील्ड दिखाते हैं और ऑब्जेक्ट से एक और सिर्फ़ एक इमेज मॉड्यूल फ़ील्ड दिखाते हैं. अगर आपको किसी भी लेवल पर, एक से ज़्यादा इमेज मॉड्यूल फ़ील्ड की ज़रूरत है, तो डिफ़ॉल्ट टेंप्लेट को बदलें.
टेक्स्ट मॉड्यूल फ़ील्ड के लिए, हम क्लास से ज़्यादा से ज़्यादा 10 टेक्स्ट मॉड्यूल फ़ील्ड और ऑब्जेक्ट से ज़्यादा से ज़्यादा 10 टेक्स्ट मॉड्यूल फ़ील्ड दिखाते हैं. फ़ील्ड उसी क्रम में दिखाए जाते हैं जिस क्रम में उन्हें श्रेणी में तय किया जाता है. अगर आपको किसी भी लेवल पर, 10 से ज़्यादा टेक्स्ट मॉड्यूल फ़ील्ड की ज़रूरत है, तो डिफ़ॉल्ट टेंप्लेट को बदलें.
मैसेज के लिए, हम कक्षा से ज़्यादा से ज़्यादा 10 मैसेज और ऑब्जेक्ट के 10 मैसेज दिखाते हैं. हम मैसेज के क्रम की गारंटी नहीं देते. अगर आपको किसी भी लेवल पर 10 से ज़्यादा मैसेज की ज़रूरत है या फिर किसी ऑर्डर की गारंटी है, तो डिफ़ॉल्ट टेंप्लेट को बदलें.
लिंक मॉड्यूल फ़ील्ड के लिए, उन यूआरआई की कोई सीमा नहीं है जिन्हें आप तय कर सकते हैं. हर लेवल (क्लास या ऑब्जेक्ट) के लिए, यूआरआई को नीचे दिए गए क्रम में बांटा जाता है:
- मैप निर्देशांक
- टेलीफ़ोन नंबर
- ईमेल पते
- वेब पेज
हर ग्रुप के लिए, यूआरआई को उसी क्रम में दिखाया जाता है जिसमें वे अरे में तय होते हैं. अगर आपको किसी दूसरे ऑर्डर की ज़रूरत है, तो डिफ़ॉल्ट टेंप्लेट को बदलें.
|
|