Hogyan dolgozzunk a views template-jeivel?

The spam filter installed on this site is currently unavailable. Per site policy, we are unable to accept new submissions until that problem is resolved. Please try resubmitting the form in a couple of minutes.
Kategória: 
Leírás

Nos, mára teljesen mást szántam, de úgy szeretném írni a postokat, hogy tényleg a legérthetőbb legyen bárki számára, ezért kénytelen vagyok egy kis kitérőt tenni, hogy a következő írások is emészthetők legyenek.
Mik azok a views template-ek, és mihez kezdjünk velük?

A views tulajdonképpen egy SQL lekérdezésből HTML kimenetet generál. A HTML kimenetbe tudunk több szinten belenyúlni. Ezek a szintek a következők:

  • A teljes nézet
  • A nézetben alkalmazott stílus
  • Sorok megjelenése (nem minden stílusban..)
  • Mezők megjelenése

Ha a views szerkesztésekor rákattintasz a Theme: Information-ra, megjelennek azok a tpl file-ok, amiket az adott nézet használ.

A Display outputnál (views-view.tpl.php) lévő tpl a nézet alapvető szerkezetéért felelős. Ő írja ki az admin linket, ez teszi helyére a felfedett szűrőket, fejlécet, láblécet, amiket beállítgattunk a views szerkeztésekor.

A Style output (views-view-stílusamithasználunk.tpl.php) tartalmazza a stílusspecifikus beállításokat, tehát ha pl táblázat megjelenést választottunk, ő készíti a táblázat fejlécét, a sorok, oszlopok formázását.

Row style output: (views-view-fields.tpl.php) Ez nincs minden esetben (pl táblázatoknál sem) . Ő már egyesével dolgozik a mezőkon, kiírja a címkét, a tartalmat a nézet beállításai szerint, gyakorlatilag egy mező html szerkezetét készíti el.

Field mezőneve: (views-view-field.tpl.php) Ezek alapesetben már csak kiírják a mező tartalmát, egyes feladatoknál viszont jó velük dolgozni, mint azt később láthatjuk majd.

Ezek bármelyikét szerkeszthetjük, de csak óvatosan! Az ezekben a file-okban végzett módosítások az össze nézetet érintik, amiket használunk.

Amikor bármilyen tpl file-al dolgozunk, sosem az eredetit írjuk felül, hanem másolatot készítünk róla a sminkünk könyvtárában. Így módosítsunk tpl-t:

A felsorolt tpl-ek közül válasszuk ki azt a szintet, amivel dolgozni szeretnénk. A szintre rákattintva betöltődik az a file, amit aktuálisan használ a views.
Egy egyszerű szövegszerkesztőbe másoljuk be a tartalmát. és végezzük el a kívánt módosításokat, majd mentsük el a saját sminkünk könyvtárába. Ezutén tölsük fel, majd kattintsunk a Rescan Templates gombra. Voila, félkövérrel máris a mi most feltöltött tplünk lesz kiemelve. Ilyen egy tpl szerkezete:

[geshifilter-drupal6]<?php // $Id: views-view-field.tpl.php,v 1.1 2008/05/16 22:22:32 merlinofchaos Exp $ /** * This template is used to print a single field in a view. It is not * actually used in default Views, as this is registered as a theme * function which has better performance. For single overrides, the * template is perfectly okay. * * Variables available: * - $view: The view object * - $field: The field handler object that can process the input * - $row: The raw SQL result that can be used * - $output: The processed output that will normally be used. * * When fetching output from the $row, this construct should be used: * $data = $row->{$field->field_alias} * * The above will guarantee that you'll always get the correct data, * regardless of any changes in the aliasing that might happen if * the view is modified. */ ?> <?php print $output; ?>[/geshifilter-drupal6]

És ami itt fontos: Ami a megjegyzésben az első <?php ?> tag között van szvsz ne töröljük ki! Azt nem hiszem, hogy az oldal funkcionalitásába beleszól (ha jól tudom, a drupal.org verziókezeléséhez kapcsolódó információkat (is) tartalmaz), viszont az ott leírt instrukciók még segítségül szolgálhatnak, ha a későbbiekben variálni kell. Én még pluszban igyekszem kitölteni saját megjegyzésekkel is, hogy képben legyek, miért babráltam..

A mentés viszont egy furfangos dolog.. Attól függően, hogy milyen néven mentjük el a tpl-t, meghatározza a hatókörét, vagyis hogy mely nézetekre lesz érvényes, és már egy órája azon agyalok, hogy hogyan lehet ezt normálisan elmagyarázni..

Szóval-szóval.. A tpl elnevezése minden esetben az alapfile-al kezdődik: views-view/ views-view-unformatted/ views-view-fields/ views-view-field Ezzel azt áruljuk el a drupalnak, hogy a fentebb felsorolt szintek közül melyikkel dolgozunk.

A szűkítéshez kettő darab kötőjelet használunk. Összesen négy szűkítési lehetőségünk van:

  • Nézet neve szerint
  • Alnézet típusa (block/page)
  • Nézet létrehozásakor megadott tag (felül a view settingsnél látható érték)
  • Alnézet típusa sorszámozva

Részletesebben:
A views-view--alnezet_tipusa.tpl.php (pl default - ez tuti van mindenkinek, vagy block/page) Ez az összes nézet azonos típusú alnézetére lesz érvényes.

Használhatjuk a Nézet nevét is: views-view--nezet_neve.tpl.php - ez elég egyértelmű.

Szűkíthetünk továbbá tag-re, ha azt a nézet létrehozásakor megadtuk: views-view--comment.tpl.php. Figyelem! Én a tageket meglehetősen szabadon használom, vagyis magyar ékezetekkel, vesszőkkel. Ha tagek szerint akarsz célozni, csak az angol abc kisbetűs karaktereit használd, különben kutyabetyár zöldséget kapsz vissza!

Menjünk tovább: megcélozhatunk alnézeteket sorszám szerint is: views-view--page-1. Itt láthatjuk, hogy a sorszám megadásához mindössze egy kötőjel szükséges.

És most ugrik a majom a vízbe! Ha eddig megértetted amit írtam, akkor talán feltűnt, hogy így biza nem tudunk konkrétan 1 azaz egy darab alnézetet belőni. Hiszen ha még mondjuk block-1-re célzunk, más nézetünkben is lehet ugyanolyan block-1.

Szóval a lényeg, hogy ezeket a paramétereket kombinálhatjuk is, szintén két kötőjellel elválasztva: views-view--nezet_neve--block-1.tpl.php. Így már tényleg az adott nézetünk egy darab alnézetét túrjuk, és semmi másra nem lesz hatással.

És még egy utolsó kitérő: A Field típusú template-ek. A mezőkre ugyanazok vonatkoznak, mint az összes többire, egyetlen kivétellel: Ha az általunk szépen, pontosan, nekünk megfelelően belőtt nézet végére két kötőjel után odabiggyesszük az (ID:) után szereplő értéket, akkor ez csakis és kizárólag arra a mezőre fog vonatkozni.
Tehát ha a kutyak_nezete harmadikként létrehozott page típusú alnézetének "tistutyafile'" nevű mezőjét szeretnénk célozni, akkor az így fog kinézni: views-view-field--kutyak_nezete--page-3--tistutyafile.tpl.php

Bármennyire is hosszúnak, és bonyolultnak tűnik ez a rizsa, igazából nincs nehéz dolgunk a nézet nevének kiválasztásakor, hiszen a Themes: Information alatt rengeteg lehetőséget felsorol ajánlásként a rendszer. Ez az írás arra hivatott, hogy segítsen megkönnyíteni, hogy melyiket is válasszuk a sok közül - remélem érthetően sikerült összeszedni..

Hozzászólások

Appreciation to my father who

Appreciation to my father who shared with me concerning this blog, this weblog is in fact amazing.|

It's remarkable in support of

It's remarkable in support of me to have a website, which is beneficial for my experience. thanks admin|

I just couldn't leave your

I just couldn't leave your website before suggesting that I actually loved the usual info an individual supply to your visitors? Is going to be back steadily to inspect new posts|

I’m not that much of a online

I’m not that much of a online reader to be honest but your blogs really nice, keep it
up! I'll go ahead and bookmark your site to come back
later. All the best

This is really interesting,

This is really interesting, You're a very skilled blogger.
I've joined your feed and look forward to seeking more of your fantastic post.
Also, I've shared your website in my social networks!

Hi there to every one,

Hi there to every one, because I am really eager of
reading this website's post to be updated on a regular basis.
It contains good material.

M.E.C Mon Electricien

M.E.C Mon Electricien Catalan
44 Rue Henry de Turenne
66100 Perpignan
0651212596

Electricien Perpignan

I know this if off topic but I'm looking into starting my own blog and
was curious what all is required to get setup? I'm assuming having a blog like yours would cost a pretty penny?
I'm not very web smart so I'm not 100% sure. Any suggestions or advice would be greatly appreciated.
Kudos

Wow! This blog looks just

Wow! This blog looks just like my old one! It's on a completely different subject but it has pretty much the same page layout and design. Wonderful choice of colors!

This excellent website truly

This excellent website truly has all the info I wanted concerning this subject and didn't know who to
ask.

Good day! This is my first

Good day! This is my first comment here so I just wanted to give
a quick shout out and say I genuinely enjoy reading through your blog posts.
Can you recommend any other blogs/websites/forums that cover the same topics?
Thanks for your time!

Hello, this weekend is

Hello, this weekend is pleasant for me, because this time i am reading this fantastic educational
piece of writing here at my home.

Hmm is anyone else having

Hmm is anyone else having problems with the pictures on this blog loading?
I'm trying to determine if its a problem on my end
or if it's the blog. Any responses would be greatly appreciated.

FlexBuild Huntington Beach Concrete Company
2520 Florida St, Huntington Beach, CA 92648
714-410-5374
suzannaweiss98719 [at] gmail [dot] com

I believe everything

I believe everything published was very reasonable. However, consider this, what if you typed a catchier
title? I am not saying your content isn't solid., but what if you added a
title to possibly get a person's attention? I mean Válasz a
hozzászólásra is a little vanilla. You could glance at Yahoo's front page and note how
they create news titles to get people interested.

You might add a related video or a pic or two to grab people interested about everything've got
to say. Just my opinion, it might bring your posts a little bit
more interesting.

Hello there! This post could

Hello there! This post could not be written any better!

Reading through this post reminds me of my old
room mate! He always kept talking about this. I will forward this article to him.

Fairly certain he will have a good read. Thanks for sharing!

Hi there, this weekend is

Hi there, this weekend is fastidious for me, since this occasion i am reading
this impressive educational piece of writing here at my home.

Genuinely when someone

Genuinely when someone doesn't understand afterward its up to other users that
they will assist, so here it takes place.

Hello, i think that i saw you

Hello, i think that i saw you visited my site so i came to “return the favor”.I
am attempting to find things to improve my web site!I suppose its ok to use
a few of your ideas!!
Jay's Santa Clarita Tree Removal Kings
26174 Las Lanas Ct, Santa Clarita, CA 91355
661-464-1270
laureljefferson09875 [at] gmail [dot] com

I must thank you for the

I must thank you for the efforts you've put in penning this blog.
I'm hoping to check out the same high-grade blog posts
from you later on as well. In truth, your creative writing abilities has motivated
me to get my very own website now ;)

Hi to all, the contents

Hi to all, the contents present at this web site are
in fact awesome for people knowledge, well, keep up the nice work fellows.

FlexBuild Huntington Beach Concrete Company
2520 Florida St, Huntington Beach, CA 92648
714-410-5374
suzannaweiss98719 [at] gmail [dot] com

Somebody essentially lend a

Somebody essentially lend a hand to make seriously posts I'd state.
This is the very first time I frequented your website page
and thus far? I amazed with the analysis you made to create this particular post
extraordinary. Wonderful activity!
Jim's San Jose Carpet Cleaning
780 S 3rd St, San Jose, CA 95112
3408-351-1063
colettemackie2641 [at] gmail [dot] com

Pretty section of content. I

Pretty section of content. I just stumbled upon your blog and in accession capital to assert that I acquire actually enjoyed account your blog posts. Any way I'll be subscribing to your augment and even I achievement you access consistently quickly.|

I every time spent my half an

I every time spent my half an hour to read this blog's posts everyday along with a cup of coffee.

Great delivery. Solid

Great delivery. Solid arguments. Keep up the great effort.

I am actually thankful to the

I am actually thankful to the holder of this
web site who has shared this fantastic piece of writing
at here.
Jay's Santa Clarita Tree Removal Kings
26174 Las Lanas Ct, Santa Clarita, CA 91355
661-464-1270
laureljefferson09875 [at] gmail [dot] com

Write more, thats all I have

Write more, thats all I have to say. Literally, it seems as though
you relied on the video to make your point.

You definitely know what youre talking about, why throw away your intelligence on just posting videos to your site when you could be giving us something enlightening to read?

Independance Immobilière -

Independance Immobilière - Agence Dakar Sénégal
Av. Fadiga, Immeuble Lahad Mbacké
BP 2975 Dakar
+221 33 823 39 30

Agence Immobilière Dakar

I'm now not certain where you are getting your info, however great topic.
I must spend a while studying much more or understanding
more. Thank you for magnificent info I was looking for this information for my mission.

Hi, its good article

Hi, its good article regarding media print, we all be familiar with media is a great source of data.

When I initially commented I

When I initially commented I clicked the "Notify me when new comments are added"
checkbox and now each time a comment is added I get three e-mails with the same comment.
Is there any way you can remove me from that
service? Many thanks!

Anaheim Divorce Lawyers in Practice
204 S Illinois St, Anaheim, CA 92805
714-410-5333
sabihafelix09835 [at] gmail [dot] com

Pretty nice post. I just

Pretty nice post. I just stumbled upon your weblog and wanted to say that
I've really enjoyed surfing around your blog posts. In any case I'll be subscribing to your
feed and I hope you write again very soon!

I am regular reader, how are

I am regular reader, how are you everybody? This post posted at this site is truly fastidious.

Heya i'm for the first time

Heya i'm for the first time here. I came across this board
and I in finding It really useful & it helped me out much.
I'm hoping to present one thing again and aid others such as you
aided me.

FlexBuild Huntington Beach Concrete Company
2520 Florida St, Huntington Beach, CA 92648
714-410-5374
suzannaweiss98719 [at] gmail [dot] com

It's going to be end of mine

It's going to be end of mine day, except before finish I am reading this
fantastic article to improve my knowledge.

Good replies in return of

Good replies in return of this question with
real arguments and telling the whole thing regarding that.

Willie G youllied If some one

Willie G youllied

If some one wishes to be updated with hottest technologies after that he must be pay a quick visit this website
and be up to date daily.

Taxi moto line 128 Rue la

Taxi moto line
128 Rue la Boétie
75008 Paris
+33 6 51 612 712  

Taxi moto paris

Nice blog right here! Also your site quite a bit up fast!
What web host are you the use of? Can I get your affiliate link in your
host? I wish my site loaded up as fast as yours lol

It's awesome for me to have a

It's awesome for me to have a site, which is good in favor of my experience. thanks admin|

My developer is trying to

My developer is trying to convince me to move to .net from PHP.

I have always disliked the idea because of the expenses.
But he's tryiong none the less. I've been using Movable-type on numerous websites for about a year
and am anxious about switching to another platform. I have heard very good things about blogengine.net.
Is there a way I can transfer all my wordpress content into it?
Any kind of help would be greatly appreciated!

I do consider all the

I do consider all the concepts you have presented on your post.
They're very convincing and will definitely work. Still,
the posts are too short for beginners. May you please prolong them a
bit from next time? Thank you for the post.

This page truly has all of

This page truly has all of the information and facts I needed about this subject
and didn't know who to ask.

When someone writes an post

When someone writes an post he/she retains the thought of a user in his/her mind that how a user can know it. Thus that's why this article is great. Thanks!|

Pretty! This was an extremely

Pretty! This was an extremely wonderful article. Thank you for providing
these details.

Hello there! This is my 1st

Hello there! This is my 1st comment here so I just wanted to give a quick shout
out and tell you I truly enjoy reading through your posts.
Can you suggest any other blogs/websites/forums that go over the same topics?
Thank you!

Anaheim Divorce Lawyers in Practice
204 S Illinois St, Anaheim, CA 92805
714-410-5333
sabihafelix09835 [at] gmail [dot] com

I all the time used to read

I all the time used to read piece of writing in news papers
but now as I am a user of internet so from now I am
using net for articles, thanks to web.

I was wondering if you ever

I was wondering if you ever thought of changing the page layout of your
site? Its very well written; I love what youve got to say.
But maybe you could a little more in the way of content so people could connect with it better.
Youve got an awful lot of text for only having 1
or 2 pictures. Maybe you could space it out better?

whoah this blog is

whoah this blog is magnificent i really like studying your articles.
Stay up the great work! You already know, a lot of individuals are looking round for this info,
you can help them greatly.

What's up, just wanted to

What's up, just wanted to say, I loved this article.
It was funny. Keep on posting!

Truly no matter if someone

Truly no matter if someone doesn't know then its up
to other users that they will assist, so here it occurs.

It's in point of fact a nice

It's in point of fact a nice and useful piece of info.
I'm glad that you just shared this useful information with us.
Please keep us informed like this. Thank you for sharing.

Jim's San Jose Carpet Cleaning
780 S 3rd St, San Jose, CA 95112
3408-351-1063
colettemackie2641 [at] gmail [dot] com

Do you mind if I quote a

Do you mind if I quote a couple of your posts as
long as I provide credit and sources back to your webpage?
My blog site is in the exact same niche as yours and my users
would really benefit from a lot of the information you present here.
Please let me know if this alright with you. Appreciate it!

If some one wants expert view

If some one wants expert view about blogging and site-building after that i recommend him/her to
pay a quick visit this website, Keep up the good job.

Hozzászólás

A mező tartalma nem nyilvános.
  • Internal paths in double quotes, written as "internal:node/99", for example, are replaced with the appropriate absolute URL or relative path.
  • Engedélyezett HTML elemek: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <del> <img>
  • A webcímek és email címek automatikusan linkekké alakulnak.
  • A sorokat és bekezdéseket a rendszer automatikusan felismeri.
  • Engedélyezett HTML elemek: <a> <blockquote> <br> <cite> <code> <dd> <del> <div> <dl> <dt> <em> <li> <ol> <p> <span> <strong> <ul>
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <bash>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <mysql>, <php>, <python>, <ruby>, <sql>. The supported tag styles are: <foo>, [foo].
  • Minden email cím át lesz alakítva ember által olvasható módon, vagy (ha a JavaScript engedélyezett) ki lesz cserélve kattintható, de biztonságos hivatkozásra.