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

  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • 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.
Category: 
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ó.

Comments

Hi to every body, it's my

Hi to every body, it's my first pay a visit of this webpage; this website contains amazing and actually good information designed
for visitors.

sfcus. elitelaunch.

Hello, I log on to your blog

Hello, I log on to your blog daily. Your story-telling style is witty,
keep it up!

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 website to come back in the future.

Cheers

Ridiculous story there. What

Ridiculous story there. What occurred after?
Take care!

Have a look at my homepage :: prednisone

Hurrah! In the end I got a

Hurrah! In the end I got a blog from where I be capable of actually get
valuable facts concerning my study and knowledge.

I'll right away grasp your

I'll right away grasp your rss feed as I can not in finding your
e-mail subscription link or newsletter service.
Do you've any? Kindly allow me recognise in order that I
may subscribe. Thanks.

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

I know this if off topic but

I know this if off topic but I'm looking into
starting my own weblog and was wondering 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 tips or advice would be greatly appreciated.
Thank you

Wow, gorgeous website. Thnx

Wow, gorgeous website. Thnx ...

I got this web page from my

I got this web page from my buddy who shared with me on the
topic of this website and at the moment this time I am
browsing this web site and reading very informative posts here.

postbkk. mercury.

Hey there! Do you know if

Hey there! Do you know if they make any plugins to protect
against hackers? I'm kinda paranoid about losing everything I've worked hard on. Any
suggestions?

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

Hurrah, that's what I was

Hurrah, that's what I was seeking for, what a material!
existing here at this webpage, thanks admin of this web page.

You're a very valuable

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

I visit day-to-day some sites

I visit day-to-day some sites and sites to
read posts, except this weblog gives feature based
content.

Ahaa, its good conversation

Ahaa, its good conversation regarding this paragraph here
at this website, I have read all that, so now me also commenting here.

It's amazing for me to have a

It's amazing for me to have a site, which is beneficial for my know-how.
thanks admin

Now I am going away to do my

Now I am going away to do my breakfast, after having my breakfast coming again to read more news.

If some one desires expert

If some one desires expert view about running a
blog afterward i propose him/her to visit this web site, Keep up the fastidious
work.

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

Hello, i think that i noticed

Hello, i think that i noticed you visited my web site thus i came to return the want?.I'm
attempting to to find things to enhance my web site!I suppose
its good enough to use a few of your concepts!!

I value the info on your

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

It's actually a nice and

It's actually a nice and helpful piece of info. I'm satisfied that you just shared this helpful information with us.
Please stay us up to date like this. Thanks for sharing.

You're an extremely useful

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

Very energetic article, I

Very energetic article, I liked that bit. Will there be a part 2?

I read this article

I read this article completely regarding the difference of most up-to-date and preceding technologies,
it's remarkable article.

And that is an investment

And that is an investment danger price taking.

Wonderful blog! I found it

Wonderful blog! I found it while surfing around on Yahoo News.
Do you have any tips on how to get listed in Yahoo News?
I've been trying for a while but I never seem to get there!
Many thanks

excellent issues altogether,

excellent issues altogether, you just won a new reader.
What would you suggest about your post that you just made a few days in the past?
Any sure?

Hello, I enjoy reading

Hello, I enjoy reading through your post.
I like to write a little comment to support you.

This paragraph gives clear

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

Having read this I believed

Having read this I believed it was very enlightening. I appreciate you taking the time and energy to put this information together.

I once again find myself spending way too much time both reading and commenting.

But so what, it was still worth it!

I believe that is one of the

I believe that is one of the such a lot important information for me.
And i'm satisfied reading your article. But want to statement on few general
things, The web site style is perfect, the articles is really excellent :
D. Good process, cheers

That is true for investment

That is true for investment recommendation as effectively.

Love the site-- very user

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

Hey There. I found your blog

Hey There. I found your blog using msn. This is a very well written article.
I will be sure to bookmark it and return to read more of your
useful information. Thanks for the post. I'll definitely comeback.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Internal paths in double quotes, written as "internal:node/99", for example, are replaced with the appropriate absolute URL or relative path.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <del> <img>
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • Allowed HTML tags: <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].
  • Each email address will be obfuscated in a human readable fashion or (if JavaScript is enabled) replaced with a spamproof clickable link.