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

Hi there! Do you use Twitter?

Hi there! Do you use Twitter? I'd like to follow you if that would be ok.
I'm definitely enjoying your blog and look forward to new posts.

Dental Plastic

I blog quite often and I

I blog quite often and I genuinely appreciate your information.
The article has truly peaked my interest. I'm going to take a note of your website and
keep checking for new information about once per week. I opted in for your
RSS feed as well.

I'm not sure where you're

I'm not sure where you're getting your info, but good topic.

I needs to spend some time learning more or understanding more.

Thanks for fantastic info I was looking for this information for my mission.

Fine way of telling, and

Fine way of telling, and pleasant article to take information about my presentation subject matter, which i am going
to convey in academy.

With havin so much content do

With havin so much content do you ever run into any problems of plagorism or copyright violation? My website has a
lot of completely unique content I've either created myself or outsourced but it appears
a lot of it is popping it up all over the web without my agreement.
Do you know any solutions to help reduce content from being stolen? I'd definitely appreciate
it.

Rubber Air Line

Hi! I know this is kind of

Hi! I know this is kind of 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 issues with hackers and I'm looking at options
for another platform. I would be great if you could point me in the direction of a
good platform.

3 Ton Digger For

3d Heat

What a data of un-ambiguity

What a data of un-ambiguity and preserveness of valuable experience regarding unexpected emotions.

Thank you for any other

Thank you for any other informative blog. The place else may
just I get that type of information written in such an ideal method?
I've a mission that I am just now operating on, and I've been at the glance out for such information.

This is a topic that's near

This is a topic that's near to my heart... Thank you!
Exactly where are your contact details though?

Fiocchi 12 Gauge Steel

Wonderful article! That is

Wonderful article! That is the kind of info that are supposed to be shared
around the web. Shame on the search engines for now not
positioning this put up higher! Come on over and seek advice from my
website . Thank you =)

Attractive component to

Attractive component to content. I just stumbled upon your weblog and in accession capital to assert that I acquire in fact enjoyed account your blog posts. Anyway I'll be subscribing in your feeds and even I success you get entry to persistently rapidly.|

Good post. I learn something

Good post. I learn something totally new and challenging on websites I stumbleupon every day. It's always exciting to read articles from other writers and use a little something from their sites. |

Amazing! This blog looks

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

Ahaa, its good conversation

Ahaa, its good conversation about this article at this place at this webpage, I have read all
that, so now me also commenting here.

I just like the helpful

I just like the helpful information you provide for your articles.
I'll bookmark your weblog and test again here regularly.

I am reasonably sure I will learn plenty of new stuff right here!
Good luck for the following!

I don't even know how I ended

I don't even know how I ended up here, but I thought this post was good.
I don't know who you are but definitely you're going to a famous blogger if
you aren't already ;) Cheers!

Hi there to every single one,

Hi there to every single one, it's actually a good for me to
visit this web site, it includes precious Information.

I would like to thank you for

I would like to thank you for the efforts you've put in penning this site. I am hoping to check out the same high-grade blog posts from you later on as well. In fact, your creative writing abilities has motivated me to get my own blog now ;)|

I'm really enjoying the

I'm really enjoying the design and layout of your blog. It's a very easy on the eyes which makes it much more pleasant for me to come here and visit more often. Did you hire out a designer to create your theme? Great work!|

Hello to all, the contents

Hello to all, the contents existing at this web site are actually remarkable for people experience, well, keep up the nice work fellows.|

It's enormous that you are

It's enormous that you are getting ideas from this piece of writing as well as from our discussion made here.|

Magnificent goods from you,

Magnificent goods from you, man. I've understand your stuff previous to and you're just
too great. I actually like what you've acquired here, certainly like what you are stating and the way in which you say it.
You make it entertaining and you still take care of to
keep it smart. I cant wait to read far more from you.
This is really a tremendous website.

Thanks for the good writeup.

Thanks for the good writeup. It actually used to be a amusement account it.
Look complex to more introduced agreeable from you! However, how can we be in contact?

What i do not understood is

What i do not understood is actually how you are now not really a lot more well-preferred than you might be right now. You are very intelligent. You understand thus considerably with regards to this topic, produced me in my view consider it from so many numerous angles. Its like men and women don't seem to be involved except it's one thing to accomplish with Lady gaga! Your individual stuffs excellent. Always take care of it up!|

You really make it seem so

You really make it seem so easy along with your presentation but I find this matter to be actually something that I believe I'd by no means understand. It sort of feels too complicated and extremely broad for me. I'm having a look ahead on your next publish, I'll attempt to get the dangle of it!|

Thank you for every other

Thank you for every other excellent post. Where else may anybody get that type of info in such a perfect way of writing? I've a presentation subsequent week, and I am on the search for such information.|

Superb blog you have here but

Superb blog you have here but I was wanting to know if you knew of any message boards that cover
the same topics talked about in this article? I'd really love
to be a part of group where I can get feed-back from other knowledgeable individuals that share
the same interest. If you have any recommendations, please let me know.
Bless you!

Hi, i think that i saw you

Hi, i think that i saw you visited my blog thus i came to “return the favor”.I am trying to find things to improve my site!I suppose its ok to use a few of your ideas!!|

Aerobic And

Right now it appears like

Right now it appears like BlogEngine is the best blogging platform out there right now. (from what I've read) Is that what you are using on your blog?|

Incredible points. Great

Incredible points. Great arguments. Keep up the amazing effort.

I think this is among the

I think this is among the such a lot vital info for me.
And i'm glad studying your article. But want to statement on some basic issues, The website style is perfect, the articles is in point of fact great : D.
Just right task, cheers

Hi there, You have done an

Hi there, You have done an excellent job. I'll definitely digg it and personally suggest to my
friends. I am confident they'll be benefited from this website.

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.