Dátumformátum + dátumformátum-típus exportálása

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

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

dnineinternational.

My brother suggested I might

My brother suggested I might like this blog. He was entirely right.
This post truly made my day. You cann't imagine just how much time
I had spent for this info! Thanks!

Feel free to surf to my page online pharmacies in canada

einstein. jabulaniholdings.

Hi there friends, pleasant

Hi there friends, pleasant paragraph and nice urging commented at this
place, I am really enjoying by these.

Also visit my blog ... canadadrugsonline.com

Terrific web site you've in

Terrific web site you've in here.

adopt10plus. florapos.

s2slc. lovran-apartments.

borsalino-verbier.

Hmm it seems like your site

Hmm it seems like your site ate my first comment (it was super
long) so I guess I'll just sum it up what I had written and say, I'm thoroughly enjoying your blog.

I as well am an aspiring blog blogger but I'm still new to everything.
Do you have any recommendations for inexperienced blog
writers? I'd definitely appreciate it.

Take a look at my web site - prednisone

Incredibly user friendly

Incredibly user friendly site. Astounding details readily available on couple of gos to.

With thanks! It is definitely

With thanks! It is definitely an astounding site!

sfcus. elitelaunch.

maplelost. 2696868.

borsalino-verbier.

Ridiculous story there. What

Ridiculous story there. What occurred after?
Take care!

Have a look at my homepage :: prednisone

stayhere. artaniumlong.

smdservicesllc. mercury.

I'm gone to inform my little

I'm gone to inform my little brother, that he should also pay
a visit this blog on regular basis to get updated from newest news.

Feel free to visit my blog post :: prednisone

Wow, gorgeous website. Thnx

Wow, gorgeous website. Thnx ...

postbkk. mercury.

clevio. lapenavigevano.

I was recommended this web

I was recommended this web site via my cousin. I
am not certain whether or not this put up is written by way of him as nobody else recognise such particular about my trouble.
You're incredible! Thank you!

Have a look at my web site ... cozaar medication

You're a very valuable

You're a very valuable website; couldn't make it without ya!

dynamicunity. marlbhouse.

ptamartamedia. maplelost.

maplelost. 2696868.

Have you ever considered

Have you ever considered about adding a little bit more than just your articles?
I mean, what you say is important and everything.

Nevertheless think of if you added some great
pictures or videos to give your posts more, "pop"! Your content is excellent but
with images and clips, this site could undeniably be one of the greatest
in its field. Fantastic blog!

Check out my weblog; prescription prices

I value the info on your

I value the info on your websites. Thanks a ton.

You're an extremely useful

You're an extremely useful web site; could not make it without ya!

smdservicesllc. newswit.

vzglyadzagran.

marlbhouse. campuscreators.

This paragraph gives clear

This paragraph gives clear idea in support of the new users of blogging, that in fact how to do blogging.

Love the site-- very user

Love the site-- very user friendly and lots to see!

educaptive. kentside-rp.

langroud118. ankorona.

Hey just wanted to give you a

Hey just wanted to give you a brief heads up and let you know a few
of the pictures aren't loading properly. I'm not sure why but
I think its a linking issue. I've tried it in two different browsers and both show the same results.

Feel free to surf to my blog - Canadian pharmacy

I delight in the content on

I delight in the content on your web site. thnx!

onsystem. unisotong.

Thank you for some other

Thank you for some other informative site. The place else could I get that type of info written in such an ideal approach?
I've a mission that I am just now operating on, and I've been on the
glance out for such info.

Here is my webpage: Canadian pharmacy

Many thanks, this website is

Many thanks, this website is really helpful.

Wow, gorgeous portal. Thnx

Wow, gorgeous portal. Thnx ...

rayanwebhost. sunyudo.

florapos. s2slc. libresite.

I always spent my half an

I always spent my half an hour to read this webpage's posts daily along with a cup
of coffee.

Here is my blog: cialis coupons online

Great looking web site.

Great looking web site. Presume you did a great deal of your very own html coding.

lapenavigevano. raviraj.

florapos. s2slc. libresite.

campuscreators.

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.