I am trying to get the number of the month with the @EVAL binding function in a TV.
I have TV named startingDate (date format) and another TV named numMonth (text format)
I made a snippet to get the number of the month named month-number Ex:
[[!month-number? &var=`[[*publishedon]]`]] it is working perfectly.
But when I use the @EVAL binding like this in the TV numMonth :
@EVAL return $modx->runSnippet('month-number',array('var'=>'[[*startingDate]]'));
I get the number 12 which is from the date Wednesday, December 31, 1969
I try with the [[*publishedon]] same result.
I think I have not the right way to pass the parameter date in the @EVAL binding.
Does someone could tell me my mistake?
Thank for your help
month-number and var are not set when the TV value is evaluated. You don't really want an @EVAL TV. You can use an output modifier to show the month number. You'll have to install PHX is you're using MODX Evolution.
Try this:
[[*startingDate:strtotime:date=`%m`]]
---------------------------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
MODX info for everyone:
http://bobsguides.com/modx.html
Sorry,sorry, I usually always mention the version of Modx. I use Modx version 2.2 .
- getResources 1.4.2
- php 5.3.8
- mySql 5.1.56
My first language is French, I'll try to explain I what to do.
Thank you for your answer, but I do not want to display the number of month, I want to filter the results of getResources by the number of the month.
I have these ressources
- Training
- course 1
- course 2
- course 3
- course n
For each course
Tv : startingDate | date format | Starting date fo a course | Enter by the user
Tv : numMonth | text format | Number of the month of the starting date | calculate with @Eval Binding in the Tv
I want to place the number of the month of the startingDate in numMonth Tv with @Eval Binding, and with getResources filter the resources by the numMonth Tv.
Is it possible? Is it the right way to do that?
Thank
Can't you just put the tag I posted above in the getResources tag where you need the month number?
---------------------------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
MODX info for everyone:
http://bobsguides.com/modx.html
You also need
&processTVs=`1`
I'm afraid tvFilters works on the raw value of the TV. Sorry if I led you down the wrong path. I didn't realize you were trying to use it with tvFilters.
You might consider either entering the numMonth TV value manually before saving the resource or creating a plugin connected to OnDocFormSave that sets it for you.
---------------------------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
MODX info for everyone:
http://bobsguides.com/modx.html
Thank you Bob, it was my first option to enter the value manually in the numMonth TV.
I'm not familiar with the plugin creation, I will read the section of your book on the subject.
Thank you again