However, the data of the last macro needs to get a class="last", so how can I determine if the macro is the last one?
My xlm in Umbraco.config looks like this:
<homepageBox><![CDATA[<?UMBRACO_MACRO macroalias="HomeBox" title="About ESHMS" image="1059" intro="A small group of devoted, internationally active scientists involved in socio-medical research initiated the foundation of European Society of Medical Sociology (ESMS) in the early 1980ies. " link="1054" /><?UMBRACO_MACRO macroalias="HomeBox" title="Apply for membership" image="1094" intro="ESHMS members benefit from a registration fees reduction for the biannual ESHMS Congress" link="1056" /><?UMBRACO_MACRO macroalias="HomeBox" title="Conferences" image="1287" intro="Past and upcoming conferences of the ESHMS" link="1100" />]]></homepageBox>
One possible solution but not ideal is to parse the string of macro container, and compare the id in the macro container string with the required node id.
E.g. not real code below
string macroContainer = Model.macroContainerAlias //parse the macroContainer here,
The problem is there is no object type for macro container.
Another way is to put a macro A after the macro for the macro container, and put logic within macro A.
Hope there are Macro Container APIs rather than using hacks.
check if macro IsLast
Hi,
I'm using a property of type macro container.
Accessing macro parameters in Razor is easy:
var title = Parameters.title
However, the data of the last macro needs to get a class="last", so how can I determine if the macro is the last one?
My xlm in Umbraco.config looks like this:
<homepageBox><![CDATA[<?UMBRACO_MACRO macroalias="HomeBox" title="About ESHMS" image="1059" intro="A small group of devoted, internationally active scientists involved in socio-medical research initiated the foundation of European Society of Medical Sociology (ESMS) in the early 1980ies. " link="1054" /><?UMBRACO_MACRO macroalias="HomeBox" title="Apply for membership" image="1094" intro="ESHMS members benefit from a registration fees reduction for the biannual ESHMS Congress" link="1056" /><?UMBRACO_MACRO macroalias="HomeBox" title="Conferences" image="1287" intro="Past and upcoming conferences of the ESHMS" link="1100" />]]></homepageBox>
Thanks for your help,
Anthony
maybe I should restate my question,
I there a way to loop through the above macro's in a razor script file (.cshtml)
thanks for your help,
Anthony
ok, I will restate my question yet another way,
In Xslt there is a way to determine if a macro is the last one:
<xsl:if test="position() = last()">
<xsl:attribute name="class">box no_margin</xsl:attribute>
</xsl:if>
Is there a way to achieve this for a macro in a Razor script (.cshtml)
Thanks for your help,
Anthony
Do you find the solution? I have the same problem.
Hi pingpong
nope, I didn't found the solution :(
Anthony
One possible solution but not ideal is to parse the string of macro container, and compare the id in the macro container string with the required node id.
E.g. not real code below
string macroContainer = Model.macroContainerAlias
//parse the macroContainer here,
The problem is there is no object type for macro container.
Another way is to put a macro A after the macro for the macro container, and put logic within macro A.
Hope there are Macro Container APIs rather than using hacks.
Hope it helps.
is working on a reply...