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
Lever Chain Hoist
Lever Chain Hoist
2 Ton Sling
2 Ton Sling
Feather Tattoo Stickers
Feather Tattoo Stickers
You're so cool! I don't think
You're so cool! I don't think I've truly read through something like that before. So good to discover someone with a few genuine thoughts on this issue. Seriously.. thank you for starting this up. This website is one thing that's needed on the web, someone with some originality!|
Star Anise Oil Supplier
Star Anise Oil Supplier
Galvanized Steel Sheet
Galvanized Steel Sheet
China Pet Products and Dog
China Pet Products and Dog Product price
Fancy Sleep Mask
Fancy Sleep Mask
Cannabis bag
Cannabis bag
you're in reality a good
you're in reality a good webmaster. The web site loading velocity is incredible. It sort of feels that you're doing any unique trick. In addition, The contents are masterwork. you have performed a excellent job on this topic!|
304 1.0mm Stainless Steel Cut
304 1.0mm Stainless Steel Cut Wire Shot
Airplane Communication Tower
Airplane Communication Tower
Uhmwpe Extrusion
Uhmwpe Extrusion
assignment company - apa
assignment company - apa annotated bibliography generator write my essay help
ACT Cooktop
ACT Cooktop
Export Pulp Packaging
Export Pulp Packaging Supplier
Bandsaw Blades Supplier
Bandsaw Blades Supplier
15kw Air Cooled Chiller
15kw Air Cooled Chiller
Multi Capsule Coffee Machine
Multi Capsule Coffee Machine
home remedies for erectile
home remedies for erectile dysfunction - natural pills for erectile dysfunction cures for ed
Wire harness fuse
Wire harness fuse
Air Comoressor Parts
Air Comoressor Parts
High Heat
High Heat
Wholesale Distributors
Wholesale Distributors
Computer Rays Protection
Computer Rays Protection Glasses Supplier
Lcd Led Tv Stand
Lcd Led Tv Stand
Hello there! I know this is
Hello there! I know this is kinda off topic but I'd figured I'd ask.
Would you be interested in exchanging links or maybe guest writing a blog
article or vice-versa? My site addresses a lot of
the same topics as yours and I think we could
greatly benefit from each other. If you are interested feel free to send me an e-mail.
I look forward to hearing from you! Terrific blog by the way!
price of ivermectin tablets -
price of ivermectin tablets - ivermectin 6 ivermectin oral
Flower Marble Mosaic Tile
Flower Marble Mosaic Tile
ivermectin malaria -
ivermectin malaria - http://ivermectipl.com/ ivermectin 6
modafinil and caffeine
modafinil and caffeine http://provipls.com/ provigil 100mg Lgthic nlokhm
Hydraulic Link Supplier
Hydraulic Link Supplier
gel tube filling sealing
gel tube filling sealing machine Supplier
buy modafinil
buy modafinil http://modafinipls.com/ provigil for adhd Gdnvju djeagr
I love reading an article
I love reading an article that will make people think.
Also, thank you for allowing me to comment!
I absolutely love your blog
I absolutely love your blog and find a lot
of your post's to be just what I'm looking for. Do you offer guest writers to
write content available for you? I wouldn't mind publishing a
post or elaborating on a few of the subjects you write related to here.
Again, awesome blog!
Hi, Neat post. There is an
Hi, Neat post. There is an issue with your web site in web explorer, would test this?
IE still is the market chief and a good part of other
people will omit your great writing because of this
problem.
Hi there! Would you mind if I
Hi there! Would you mind if I share your blog with my zynga group?
There's a lot of folks that I think would really appreciate your content.
Please let me know. Thanks
buy nothing day essay
buy nothing day essay http://ivermectinpls.com/ writing assignments Ktqife avlfmt
Amorphous Core Reactor Core
Amorphous Core Reactor Core
If some one needs expert view
If some one needs expert view regarding blogging and site-building afterward i
propose him/her to go to see this weblog, Keep up the pleasant work.
Transparent Chelated Silver
Transparent Chelated Silver Solutions
Spoon Set
Spoon Set
help with term paper
help with term paper http://geivermectin.com/ affordable essay writing Mqxvmj putdsp
30 Ml Roller Ball Bottle
30 Ml Roller Ball Bottle
Disposable 3ply Face Mask
Disposable 3ply Face Mask
my future essay writing
my future essay writing http://boessay.com/ write my paper Znaaln uxfjjt
This article will assist the
This article will assist the internet viewers for building up new
website or even a blog from start to end.
online casino
online casino http://cacinobz.com/ online slots real money Rcoqsc zvgupb
great points altogether, you
great points altogether, you simply gained a new reader. What may you recommend in regards to your publish that you just made a few days in the past?
Any certain?
Hozzászólás