الگو:جعبه رنگی متن

(تغییرمسیر از الگو:Divbox)
توضیحات الگو[نمایش] [ویرایش] [تاریخچه] [پاکسازی]

از این الگو می‌توان به‌منظور ایجاد یک پس‌زمینهٔ رنگی ساده و منعطف برای متون استفاده کرد.

لطفاً توجه داشته باشید که این الگو یک الگوی تزئینی است و برای استفاده از صفحه‌های محتوایی دانشنامه (مقاله‌ها) طراحی نشده است. این الگو در مقاله‌های فضای نام اصلی نمایش داده نمی‌شود.

کاربرد ویرایش

الگوهای جعبه‌ای فراوانی در ویکی‌پدیا وجود دارند. برای مثال:

گاهی ممکن است این جعبه‌ها مناسب کاربرد مورد نظر ما نباشند؛ این جعبه‌ها ممکن است مزاحم کار ما باشند. اما هنگامی که از جعبه‌ها استفاده می‌شود، عموماً این جعبه‌ها به‌صورت تک‌کاربردی به‌کار می‌روند. این موضوع منجر به ایجاد ناهماهنگی ظاهری می‌شود.

استفاده از {{جعبه رنگی متن}} روشی آسان برای نمایش یک متن درون یک جعبه است. رنگ‌ها در این الگو از طریق یک کلیدواژهٔ سبکی مخفی انتخاب می‌شوند که هم حاشیهٔ جعبه، و هم رنگ پس‌زمینهٔ آن را تنظیم می‌کنند؛ تنظیماتی که از پیش برای هماهنگی بصری با یکدیگر انتخاب شده‌اند.

کلیدواژهٔ هیچ (یا none) محتوای مورد نظر شما را درون یک جعبهٔ نامرئی قرار می‌دهد. این قابلیت باعث می‌شود تا متن شما در قالب یک جعبه نمایش داده شود، اما خود جعبه دیده نشود و مخفی بماند.

این الگو را می‌توان درون الگوهای دیگر، یا به‌عنوان بخشی از یک صفحهٔ دیگر به‌کار برد.

استفاده ویرایش

نحو استفاده از الگو به شکل زیر است:

{{جعبه رنگی متن|1=سبک|2=عنوان|3=متن|شعاع=|سبک=سبک سفارشی}}

پارامترها ویرایش

1 (نام سبک)
وارد کردن این پارامتر الزامی است. سبک‌های تعریف‌شده:
می‌توانید از «1=» چشم‌پوشی کنید، اما در آن صورت باید مقدار این پارامتر را در جای دقیق و پس از نخستین نویسهٔ لوله قرار دهید.
2 (عنوان)
استفاده از این پارامتر اختیاری است. باید حاوی متن ساده باشد؛ به‌شکل پررنگ و در وسط، بالای جعبه نمایش می‌یابد. می‌توانید از «2=» چشم‌پوشی کنید، اما در آن صورت باید مقدار این پارامتر را در جای دقیق و پس از دومین نویسهٔ لوله قرار دهید.
3 (محتوا)
وارد کردن این پارامتر الزامی است. می‌تواند حاوی هر محتوایی، از جمله نشانه‌گذاری ویکی باشد و برای شکل‌دهی متن داخل جعبه کاربرد دارد. می‌توانید از «3=» چشم‌پوشی کنید، اما در آن صورت باید مقدار این پارامتر را در جای دقیق و پس از دومین نویسهٔ لوله قرار دهید و متن وارد شده نیز نباید حاوی علاوت مساوی (=) باشد.
شعاع
شعاع گوشه‌های گرد جعبه، به‌همراه یک واحد معتبر نظیر px یا pt یا em (عدد حتماً باید به انگلیسی وارد شود). این پارامتر در هر دو نوع از سبک‌هایی که دارای گوشه‌های گرد یا تیز هستند، کار می‌کند و جایگزین مقدار گردی پیش‌فرض گوشه‌ها در سبک مورد نظر می‌شود. می‌توانید از این پارامتر و مقدار آن به‌طور کامل چشم‌پوشی کنید؛ اما در صورت استفاده، نمی‌توانید «شعاع=» را حذف کنید. با این حال، مانند هر پارامتر نام‌گذاری‌شدهٔ دیگر، می‌توانید این پارامتر را در هرکجای دستور فراخوانی الگو قرار دهید (یعنی نیازی نیست که این پارامتر حتماً آخرین پارامتر باشد).

نمونه‌ها ویرایش

آنچه می‌بینید آنچه تایپ می‌کنید
خاکستری: {{جعبه رنگی متن|خاکستری|طرح‌نمانوشته|طرح‌نمانوشته‌ای بی‌جهت، جهت آزمایش...}}
قرمز: {{جعبه رنگی متن|شعاع=5px|قرمز|طرح‌نمانوشته|طرح‌نمانوشته‌ای بی‌جهت، جهت آزمایش...}}
سرمه‌ای: {{جعبه رنگی متن|شعاع=10px|سرمه‌ای|طرح‌نمانوشته|طرح‌نمانوشته‌ای بی‌جهت، جهت آزمایش...}}
کهربایی: {{جعبه رنگی متن|شعاع=15px|کهربایی|طرح‌نمانوشته|طرح‌نمانوشته‌ای بی‌جهت، جهت آزمایش...}}
بدون حاشیه و پس‌زمینه: {{جعبه رنگی متن|هیچ|طرح‌نمانوشته|طرح‌نمانوشته‌ای بی‌جهت، جهت آزمایش...}}
بدون عنوان {{جعبه رنگی متن|زرد||طرح‌نمانوشته‌ای بی‌جهت، جهت آزمایش...}}
متن حاوی «=»: {{جعبه رنگی متن|ارغوانی|طرح‌نمانوشته|3=طرح‌نمانوشته‌ای <span style="color:#F00;">بی‌جهت</span>، جهت آزمایش...}}

استفاده از جا: به‌همراه این الگو ویرایش

The subst: atom may be used with {{divbox}}. This may be highly desirable. Note that subst: does not take effect in preview, but only after saving a page. The template's inclusion is replaced by the code of the template itself, which will continue to write the box as before, but without an additional server call.

Since {{divbox}} itself calls a template based on your choice of style keyword, you will find that even after saving an instance of use with subst: there remains a "live" call to the underlying style template. This means that viewing the page risks a server call to the style template, but also means that changes to the style template automatically propagate to all pages where it is used. This way, all {{divbox}}-type boxes, wherever they are in the project, keep the same consistent look.

Just paste in your content and, when you're finished, be sure to close the template call with }}.

Since the contents are given in the form of two parameter values, for the content you may place within {{divbox}}, the restrictions on parameter values apply. For example, if you put content that includes template calls, {{divbox}} cannot tell where its last parameter ends.

If the contents do not satisfy the restrictions, insert this code in your page first:

{{subst:divbox|keyword|title|DUMMYCONTENT}}

That is, choose your style and title as usual (or omit the title with two pipes), but instead of actual content, write "DUMMYCONTENT". Then, save the page and reopen it for editing. You'll see the box code in all its gory detail, and the placeholder DUMMYCONTENT, followed by the HTML division closing tag. Now, you may simply replace DUMMYCONTENT with your content, save, and move on. Since almost anything may be placed within division tags, this should not break no matter what you do.

Making new divbox styles ویرایش

I'd rather hope you were able to find joy within the existing set of styles, but if not, you can create new ones. Follow these instructions to be sure your new style will "play nice" with {{divbox}}. Note that this requires some understanding of CSS.

  1. Experiment in a drawing program, such as GraphicConverter or Adobe Photoshop, and decide what colors you want for your new box style. You need to find out the HTML color codes for each color.
  2. Open an existing box style template, such as {{divbox/style/red}}. Copy out the code.
  3. Create a new box style template page. It must be located in main Template namespace and must be named Template:divbox/style/XXXXX, where "XXXXX" is your new style name.
  4. Paste in the "borrowed" code and replace the color codes with your new, chosen colors. Save the new template.
  5. Return to this Talk page and add your new style to this documentation. Remember, a job's not over until the paperwork is done!

Note that you may even change the division box margins and paddings. This is not recommended. There are a couple of good reasons for specifying these values, and in these units. Most users who "roll their own" make choices with unintended consequences; {divbox} is meant to help you avoid these pitfalls.

الگوهای وابسته ویرایش

There are several meta-templates in the mbox family:

  • {{ambox}} – For article message boxes.
  • {{cmbox}} – For category message boxes.
  • {{imbox}} – For file (image) page message boxes.
  • {{mbox}} – Has namespace detection, for message boxes that are used on several types of pages and thus need to change style depending on what page they are used on.
  • {{ombox}} – For other pages message boxes.
  • {{tmbox}} – For talk page message boxes.

Closely related meta-templates:

  • {{asbox}} – For article stub message boxes.
  • {{dmbox}} – For disambiguation and set index message boxes.
  • {{fmbox}} – For header and footer message boxes.