Features és a saját dátumformátumok/típusok összakalapálása már több éves issue. Nálam szinte minden projectnél előjön, a #drupal.hu irc csatornán is felmerül rendszeresen.
A feladat tehát a következő: Legyen egy kódbázisban tárolt, újrafelhasználható, tetszőleges dátumformátum-típus, amely egy dátumformátumhoz van rendelve.
No de mi ez a dátumformátum, és dátumformátum-típus?
Dátumformátum-típus: A php date függvényének a paramétere. Maga a string, amely a date() függvény kimenetét produálja, pl: M d, Y - G:i
Dátumformátum: Ez már a drupal saját vuduja. Egy típusnak három paramétere lehet:
- type - A típus elnevezése
- format - A dátumformátum stringje
- locale - A nyelvek tömbje, amelyre a dátumformátumok alkalmazhatók, ha nincs megadva, akkor nyelvfüggetlen a beállítás.
Ahhoz, hogy nekünk kód alapú dátumformátumunk legyen, két hookkal kell dolgozni:
Dátumformátum
[geshifilter-drupal6]
function MYMODULE_hook_date_formats() {
return array(
array(
'type' => 'M_d_yyyy_G_i', #ez csak a gépi név, lehet bármi, én így szeretem, hogy a kulcs némileg követi az eredményt.
'format' => 'M d, Y - G:i',
'locales' => array(), #nincs nyelvi korlátozás
),
)
}[/geshifilter-drupal6]
Dátumformátum-típus
Itt fontos, hogy a kulcs megegyezzen a hook_date_formats() 'type' paraméterével. Az érték az admin/config/regional/date-time oldalon fog megjelenni, valahogy így:
[geshifilter-drupal6]function MYMODULE_hook_date_format_types() { return array( 'M_d_yyyy_G_i' => t('Example: Feb 5, 2013 - 14:09 (M d, Y - G:i)'), ); }[/geshifilter-drupal6]
Ezzel még viszont nincs vége. Ami a kettőt összekapcsolja, az egy változó, mégpedig a date_format_[type], tehát esetünkben a date_format_M_d_yyyy_G_i. Ha az adott typehoz egyetlen formatot vettünk fel, akkor csak az admin/config/regional/date-time oldalon kell nyomni egy save-t.
Ha ez kész van, mehet feature-be a változó.
Hozzászólások
Heya i am for the first time
Heya i am for the first time here. I came across this board and I find It really useful & it helped me out a lot. I hope to give something back and aid others like you helped me.|
Hey! I realize this is
Hey! I realize this is somewhat off-topic however I needed to ask. Does running a well-established website such as yours require a massive amount work? I am brand new to blogging however I do write in my journal everyday. I'd like to start a blog so I can share my own experience and feelings online. Please let me know if you have any recommendations or tips for brand new aspiring bloggers. Thankyou!|
It's remarkable to pay a
It's remarkable to pay a visit this site and reading the views of all friends about this post, while I am also keen of getting know-how.|
I am really happy to glance
I am really happy to glance at this weblog posts which includes plenty of helpful information, thanks for providing
these information.
Thank you for the auspicious
Thank you for the auspicious writeup. It if truth be told used to be a amusement account it. Glance complex to more added agreeable from you! By the way, how can we keep in touch?|
I'm not sure why but this web
I'm not sure why but this web site is loading very slow for me. Is anyone else having this problem or is it a issue on my end? I'll check back later on and see if the problem still exists.|
Wow, wonderful blog layout!
Wow, wonderful blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your web site is magnificent, as well as the content!|
certainly like your website
certainly like your website however you need to test the spelling on quite a few of your posts.
Many of them are rife with spelling problems and I in finding it very bothersome to inform the truth on the other hand I'll certainly come again again.
I am sure this post has
I am sure this post has touched all the internet viewers, its really really nice article on building up new weblog.|
Attractive section of
Attractive section of content. I simply stumbled upon your weblog and in accession capital to assert that I acquire actually loved account your blog posts. Any way I'll be subscribing in your feeds or even I achievement you get right of entry to constantly quickly.|
Ahaa, its nice conversation
Ahaa, its nice conversation regarding this paragraph here at this
webpage, I have read all that, so at this time me also commenting at this place.
I know this if off topic but
I know this if off topic but I'm looking into starting my own weblog 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 savvy so I'm not 100% sure.
Any suggestions or advice would be greatly appreciated. Many thanks
Hi there I am so grateful I
Hi there I am so grateful I found your weblog, I really found you by mistake, while I was looking on Digg for something else, Nonetheless I am here now and would just like to say cheers for a fantastic post and a all round interesting blog (I also love the theme/design), I don’t have time to read it all at the minute but I have saved it and also included your RSS feeds, so when I have time I will be back to read a great deal more, Please do keep up the fantastic b.|
It's really very difficult in
It's really very difficult in this busy life to listen news on Television, so I only use world wide web for that reason, and obtain the latest information.|
If some one wants expert view
If some one wants expert view about running a blog after that i suggest him/her to pay a visit this weblog, Keep up the fastidious work.|
Hello my family member! I
Hello my family member! I wish to say that this
post is awesome, great written and include almost all significant infos.
I would like to look more posts like this .
I do not know whether it's
I do not know whether it's just me or if everybody else encountering problems with your blog.
It appears as if some of the text on your posts are running off
the screen. Can someone else please provide feedback and let me know if
this is happening to them as well? This might be a
problem with my web browser because I've had this happen before.
Kudos
If you wish for to grow your
If you wish for to grow your experience only keep visiting this website and be updated with the latest gossip posted here.
Hard Emamel Pin Supplier
Hard Emamel Pin Supplier
China Animal Protected Fence
China Animal Protected Fence
Spot on with this write-up, I
Spot on with this write-up, I honestly think this website needs far more attention. I'll probably be returning to see more, thanks for the advice!|
Cctv Communication Cable
Cctv Communication Cable
Clean Room Air Conditioner
Clean Room Air Conditioner
Steel Structure House
Steel Structure House
Greetings, I think your
Greetings, I think your website could be having
browser compatibility problems. Whenever I look at your blog
in Safari, it looks fine but when opening in I.E., it's got
some overlapping issues. I just wanted to give
you a quick heads up! Apart from that, fantastic
blog!
Glyphosate 480g/l SL
Glyphosate 480g/l SL
Rainproof Coats
Rainproof Coats
After looking at a few of the
After looking at a few of the blog articles on your
blog, I seriously like your technique of writing a blog. I book-marked it to my bookmark webpage list and will
be checking back in the near future. Take a look at my web site too and let me know your opinion.
Mobile Lifting Column
Mobile Lifting Column
Novelty Slippers For Women
Novelty Slippers For Women
HENAN SINOKONG TRADING CO.,
HENAN SINOKONG TRADING CO., LTD.
This article is in fact a
This article is in fact a pleasant one it assists new web users, who are wishing in favor of blogging.
Awesome blog! Is your theme
Awesome blog! Is your theme custom made or did you download it from somewhere? A theme like yours with a few simple tweeks would really make my blog shine. Please let me know where you got your design. Thanks a lot|
Thanks for sharing your
Thanks for sharing your thoughts about %meta_keyword%. Regards|
Link exchange is nothing else
Link exchange is nothing else but it is simply placing the
other person's web site link on your page at suitable place and
other person will also do similar in support of you.
I always spent my half an
I always spent my half an hour to read this blog's articles everyday along with a cup of coffee.|
It's amazing in support of me
It's amazing in support of me to have a site, which is good designed for my knowledge. thanks admin|
Good answer back in return of
Good answer back in return of this matter with genuine arguments and describing all concerning that.|
Do you have any video of
Do you have any video of that? I'd care to find out some additional information.
Hey there! I know this is
Hey there! I know this is somewhat off topic but I was wondering which blog platform are you using for this website? I'm getting tired of Wordpress because I've had problems with hackers and I'm looking at alternatives for another platform. I would be awesome if you could point me in the direction of a good platform.|
I am sure this post has
I am sure this post has touched all the internet people, its really really nice article on building up new website.|
Generally I don't read
Generally I don't read article on blogs, but I wish to say that this write-up very compelled me to try and do it! Your writing style has been amazed me. Thank you, quite nice article.|
I like it whenever people
I like it whenever people come together and share ideas. Great blog, keep it up!|
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 obviously know what youre talking about,
why throw away your intelligence on just posting videos to your weblog when you could be giving us something
informative to read?
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 obviously know what youre talking about, why waste your intelligence on just posting videos to your site when you could be giving us something enlightening to read?|
We stumbled over here from a
We stumbled over here from a different web page
and thought I might as well check things out. I like what I
see so now i am following you. Look forward to looking over your web page again.
What i don't understood is in
What i don't understood is in truth how you're now not really much more neatly-preferred than you might be now. You are very intelligent. You realize thus significantly on the subject of this matter, made me for my part believe it from a lot of various angles. Its like men and women don't seem to be interested until it is one thing to do with Woman gaga! Your own stuffs excellent. All the time deal with it up!|
Attractive component of
Attractive component of content. I simply stumbled upon your weblog and in accession capital to claim that I get actually enjoyed account your weblog posts. Any way I'll be subscribing in your feeds and even I achievement you get entry to consistently quickly.|
Hello there! I know this is
Hello there! I know this is kinda off topic but I was wondering which blog platform are you using for this website? I'm getting tired of Wordpress because I've had problems with hackers and I'm looking at alternatives for another platform. I would be awesome if you could point me in the direction of a good platform.|
If you want to take much from
If you want to take much from this piece of writing then you have to apply these strategies to your won webpage.|
Hozzászólás