Support » Plugin: Dynamics 365 Integration » How can I add a function to Twig?

  • Resolved Jon Brain

    (@brainjonbrain)


    Hello,

    I’m trying to add a new function to the plugin’s implementation of Twig, to allow me to perform some string manipulation on data pulled from Alexa. I think I can use the hook “wordpresscrm_after_twig_ready” to hang my function definition on. However, my function seems to be ignored by Twig (when I try to use the function I get an error).

    Can you please point me in the right direction to work out what I’m doing wrong? I’m using the premium version of the plugin, if that helps. Thank you.

    The hook looks like this:

    do_action( 'wordpresscrm_after_twig_ready', $twigEnv );

    Location: /wp-content/plugins/integration-dynamics/src/Shortcode/Twig.php

    My code looks like this:

    function bespoke_twig( $twigEnv ) {
    
        $urlifyFunction = new \Twig_SimpleFunction( 'urlify', function( $string ) {
    
            /* manipulate $string here */
    
            return $string;
        } );
    
        $twigEnv->addFunction( $urlifyFunction );
    
        return $twigEnv; 
     } 
    
    add_action('wordpresscrm_after_twig_ready', 'bespoke_twig', 10, 1);

    Location: functions.php

    The error looks like this:

    Template syntax error: Unknown "urlify" function in "template" at line 1.

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author alexacrm

    (@alexacrm)

    Hi Jon,

    I think wordpresscrm_after_twig_ready is a tad too late for hooking the custom function but let me confirm with devs what’s the right place.

    Since you’re premium subscriber, can you also ping us at support@alexacrm.com for speedier resolution?

    Thanks
    George

    Jon Brain

    (@brainjonbrain)

    Thanks George – I’ve emailed your support team as requested.

    Jon

    Plugin Contributor wizardist

    (@wizardist)

    Hi Jon,

    The code you’re using looks correct, and I checked – it works just fine. Are you sure you’re editing the functions.php file of the active theme? Also, where do you call add_action()? Inside another action handler or in the outermost scope of the file?

    Pavel

    Jon Brain

    (@brainjonbrain)

    Hi @wizardist

    The function is in an include called by functions.php – there are a few other functions in the include, and they’re working as expected. The add_action() is in the outermost scope of the file.

    Do you think there might be some kind of caching active that might be circumventing my code?

    Thanks,
    Jon

    Plugin Contributor wizardist

    (@wizardist)

    Caching was not my original idea, it was rather order of execution, i.e. add_action() being called after the action has been already emitted. As for caching, could you share your environment details? Also, try dropping the Twig cache if it’s enabled (wp-content/uploads/wpcrm-storage/twig/*).

    WordPress version, plugins, PHP version, things like executing inside VirtualBox with a shared folder mounted, etc. Anything can be relevant, because this is super-weird as I have the same exact code running just fine.

    Jon Brain

    (@brainjonbrain)

    Thanks @wizardist.

    Really odd that you are not seeing any error. How are you trying to call the function? I’m calling it within the context of the [msdyncrm_inline] shortcode, if that helps.

    Dropping the cache has no effect.

    Here are the environment details:
    PHP: 7.0.30 (detailed info here: http://westsidelondonhosting.co.uk/phpinfo.php)
    Wordpress: 4.9.7
    Plugins:
    Advanced Custom Fields Pro: 5.6.4
    All in one Favicon: 4.6
    Dynamics 365 Integration: 1.2.13
    Dynamics 365 Integration Premium: 1.2.3
    Gravity Forms: 2.2.6.5
    Gravity Forms Event Tracking: 2.1.1
    Gravity Forms User Registration Add-On: 3.9
    WP SEO HTML Sitemap: 0.9.6
    Yoast SEO: 7.8

    Plugin Contributor wizardist

    (@wizardist)

    Oh, noes. [msdyncrm_inline] is deprecated in favor of a more powerful [msdyncrm_twig].

    HTH

    Jon Brain

    (@brainjonbrain)

    Thanks for that @wizardist – it hasn’t changed the outcome, though.

    Did you have any further thoughts having seen the environment details?

    Plugin Author alexacrm

    (@alexacrm)

    Jon,

    [msdyncrm_inline] is not supposed to support twig at all. Can you share the [msdyncrm_twig] fragment of your page where you invoke the function?

    Thanks
    George

    Jon Brain

    (@brainjonbrain)

    Hi @alexacrm,

    Actually, I made a mistake when I said replacing [msdyncrm_inline] with [msdyncrm_twig] didn’t affect the site – in fact, it stopped the query working.

    Here’s the [msdyncrm_inline] snippet. Importantly, when [msdyncrm_twig] was used it didn’t complain about the new function, so I suspect it might be accepting it. However, since the change of shortcode broke the query I now need to work out a way of using [msdyncrm_twig] so I can confirm using [msdyncrm_inline] was the problem.

    I’m new to Twig, so any pointers you can give me will be great – but don’t feel you have to.

    Thanks,
    Jon

    <?php echo do_shortcode("[msdyncrm_inline]
    							{% block fetchxml %}
    							<fetch distinct='false' mapping='logical' output-format='xml-platform' version='1.0'>
    								<entity name='new_building'>
    									<attribute name='new_buildingid'/>
    									<attribute name='new_name'/>
    									<attribute name='new_providerid'/>
    									<attribute name='new_address1_line1'/>
    									<attribute name='new_address1_line2'/>
    									<attribute name='new_address1_line3'/>
    									<attribute name='new_address1_city'/>
    									<attribute name='new_address1_stateorprovince'/>
    									<attribute name='new_address1_postalcode'/>
    									<attribute name='new_lowersize'/>
    									<attribute name='new_uppersize'/>
    									<attribute name='new_costlower'/>
    									<attribute name='new_costhigher'/>
    									<attribute name='new_latitude' />
    									<attribute name='new_longitude' />
    									<attribute name='new_managedofficespace'/>
    									<attribute name='new_servicedoffice'/>
    									<attribute name='new_coworkingspace'/>
    									<attribute name='new_virtualoffices'/>
    									<attribute name='new_leasedoffice'/>
    									<attribute name='new_buildingdescription'/>
    									<attribute name='new_locationdescription'/>
    									<attribute name='new_nearesttube'/>
    									<link-entity name='po_powerphoto' from='po_oid' to='new_buildingid' link-type='outer' alias='pp'>
    										<attribute name='po_powerphotoid'/>
    										<attribute name='po_oid'/>
    										<attribute name='po_defaultimage'/>
    										<order attribute = 'po_oid' descending='true'/>
    										<order attribute = 'po_defaultimage' descending = 'true' />
    										<filter type='and'>
    											<condition attribute='po_defaultimage' value='1' operator='eq'/>
    										</filter>
    				        			</link-entity>
    									<filter type='and'>".$spacefilter.$facfilter."
    										<condition attribute='statecode' value='0' operator='eq'/>
    										<condition attribute='new_latitude' value='".$lat1."' operator='ge'/>
    										<condition attribute='new_latitude' value='".$lat2."' operator='le'/>
    										<condition attribute='new_longitude' value='".$lng1."' operator='ge'/>
    										<condition attribute='new_longitude' value='".$lng2."' operator='le'/>
    										<filter type='or'>
    											<filter type='and'>
    												<filter type='or'>
    													<condition attribute='new_lowersize' value='".$low."' operator='le'/>
    													<condition attribute='new_lowersize' operator='null'/>
    												</filter>
    												<filter type='or'>
    													<condition attribute='new_uppersize' value='".$low."' operator='ge'/>
    													<condition attribute='new_uppersize' operator='null'/>
    												</filter>
    											</filter>
    											<filter type='and'>
    												<filter type='or'>
    													<condition attribute='new_lowersize' value='".$high."' operator='le'/>
    													<condition attribute='new_lowersize' operator='null'/>
    												</filter>
    												<filter type='or'>
    													<condition attribute='new_uppersize' value='".$high."' operator='ge'/>
    													<condition attribute='new_uppersize' operator='null'/>
    												</filter>
    											</filter>
    										</filter>
    									</filter>
    								</entity>
    							</fetch>
    							{% endblock %}
    							{% block template %}
    								{% spaceless %}
    								{% set previd = null %}
    								{% set nextid = null %}
    								<div id='sortme'>
    					    			{% for record in records %}
    						    			{% set nextid = records[loop.index0 + 1].new_buildingid %}
    						    			{% if record.new_buildingid != previd %}'
    						    				<div class='result' data-id='{{record.new_buildingid}}' data-location='{{ urlify(record.new_name) }}' data-location-test='{{ record.new_name|e('url') }}' data-lat='{{record.new_latitude}}' data-lng='{{record.new_longitude}}' data-price='{{record.new_costlower}}'>
    						    						<div class='result-slide'>
    										{% endif %}
    
    										{% if record.pp.po_powerphotoid %}<div class='result-image' style='background-image:url(/wp-admin/admin-ajax.php?action=msdyncrm_image&id={{record.pp.po_powerphotoid}}&width=800);'></div>{% else %}<div class='result-image' style='background-image:url(/wp-content/themes/cornerstone/assets/img/CS_Default-Image.png);'></div>{% endif %}
    
    										{% if record.new_buildingid != nextid %}
    													</div>
    													<div class='result-content'>
    														<div class='result-text'>
    									 						<h2>{{record.new_name}}</h2>
    									 						<h3>{{record.new_address1_line3}}{% if record.new_address1_line3 and record.new_address1_city %}, {% endif %}{{record.new_address1_city}}</h3>
    															<p>{{record.new_buildingdescription[:125]}}{% if record.new_buildingdescription %}...{% endif %}</p>
    									 					</div>
    										 				<div class='result-details'>
    										 					<div class='row'>
    										 						<div class='category {% if record.new_managedofficespace == 1 %}category-flexiblemanaged{% elseif record.new_servicedoffice == 1  %}category-servicedoffice{% elseif record.new_coworkingspace == 1  %}category-co-working{% elseif record.new_virtualoffices == 1  %}category-virtualoffice{% elseif record.new_leasedoffice == 1  %}category-leasedoffice{% endif %}'>
    										 							<p>{% if record.new_managedofficespace == 1 %}Flexible Managed{% elseif record.new_servicedoffice == 1  %}Serviced Office{% elseif record.new_coworkingspace == 1  %}Co-Working{% elseif record.new_virtualoffices == 1  %}Virtual Office{% elseif record.new_leasedoffice == 1  %}Leased Office{% endif %}</p>
    										 							<div class='result-info'>
    											 							<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 19.94 19.94'><path d='M10,19.94a10,10,0,1,1,10-10A10,10,0,0,1,10,19.94ZM10,1a9,9,0,1,0,9,9A9,9,0,0,0,10,1ZM7.37,6.08a4.71,4.71,0,0,1,.5-.39,3.74,3.74,0,0,1,.59-.33,3.57,3.57,0,0,1,.69-.22A3.77,3.77,0,0,1,10,5.05,3.33,3.33,0,0,1,11,5.22a2.46,2.46,0,0,1,.84.47,2.18,2.18,0,0,1,.55.73,2.27,2.27,0,0,1,.2,1,2.48,2.48,0,0,1-.16.93A2.59,2.59,0,0,1,12,9a3.13,3.13,0,0,1-.53.51L11,9.92a3.75,3.75,0,0,0-.43.38.76.76,0,0,0-.22.42l-.14,1.07H9.25l-.1-1.17a.87.87,0,0,1,.11-.57,2,2,0,0,1,.39-.45,5.44,5.44,0,0,1,.53-.41,4,4,0,0,0,.54-.44,2.39,2.39,0,0,0,.42-.55,1.5,1.5,0,0,0,.17-.73,1.19,1.19,0,0,0-.11-.53,1.2,1.2,0,0,0-.31-.4,1.39,1.39,0,0,0-.47-.26,1.82,1.82,0,0,0-.57-.09,2.23,2.23,0,0,0-.72.1,3,3,0,0,0-.51.22,3.34,3.34,0,0,0-.34.22.41.41,0,0,1-.23.1.31.31,0,0,1-.3-.18Zm1.38,8.46a.93.93,0,0,1,.56-.86.91.91,0,0,1,.37-.07.89.89,0,0,1,.36.07,1,1,0,0,1,.5.5.89.89,0,0,1,.07.36.91.91,0,0,1-.07.37,1,1,0,0,1-.2.3.9.9,0,0,1-.3.2.93.93,0,0,1-.36.07,1,1,0,0,1-.37-.07A.87.87,0,0,1,9,15.2a.93.93,0,0,1-.19-.3A1,1,0,0,1,8.75,14.53Z' transform='translate(0 0)'/></svg>
    											 							<div class='tooltip-info'>{% if record.new_managedofficespace == 1 %}A managed office allows you to have a bespoke fit-out and arrange your own IT and telecoms, but in a fairly flexible manner in relation to contract commitment. One operator will take care of all elements including moving in and out, customisation and making sure the space fits your business needs.{% elseif record.new_servicedoffice == 1  %}'The full package’ option with negotiable contract length. A serviced office is your one-stop shop for a dedicated and private office for your company and come with internet and telecoms within the offering. For short or longer term arrangements, serviced offices offer a flexible but professional feel that allows growth and in an ever-changing business climate.{% elseif record.new_coworkingspace == 1  %}Ideal for sole traders, start-ups and those who just thrive on collaboration; co-working space provides you with a hot-desk or designated bank of desks within a building that incorporates other businesses. A straightforward option where you can rock up with a laptop and just get stuff done without the commitment of an entire office.{% elseif record.new_virtualoffices == 1  %}A great option for those who don’t yet need a work space, or for businesses that don’t require a base. A virtual office will provide a prestigious registered address where mail can be sent and organised, a telephone number and call answering or forwarding services, plus offer business facilities should you need them.{% elseif record.new_leasedoffice == 1  %}A leased office is the business version of buying a house. Similar to a mortgage, you will have a long term loan on the property (leases are for contract terms of 5 years+) and be solely in charge of what goes on under its roof. A leased option is perfect for established companies who are relatively stable in terms of growth and location.{% endif %}</div>
    										 							</div>
    										 						</div>
    										 						<div data-id='{{record.id}}' class='featured-shortlist'></div>
    										 					</div>
    										 					<div class='row'>
    										 						<ul>
    																	<li>{{record.new_lowersize}} - {{record.new_uppersize}}</li>
    																	<li>{% if record.new_costlower %}From £{{record.new_costlower}}{% else %}£POA{% endif %}</li>
    																</ul>
    										 					</div>
    										 					<div class='row'>
    										 						<div class='tube'>
    										 							<p>{{record.new_nearesttube}}</p>
    										 						</div>
    										 					</div>
    										 				</div>
    										 			</div>
    										 		</div>
    						    			{% endif %}
    						    			{% set previd = record.new_buildingid %}
    					    			{% endfor %}
    				    			</div>
    				    		{% endspaceless %}
    							{% endblock %}
    						[/msdyncrm_inline]"); ?>
    Jon Brain

    (@brainjonbrain)

    I’ll post that snippet again:

    <?php echo do_shortcode("[msdyncrm_inline]
    	{% block fetchxml %}
    	<fetch distinct='false' mapping='logical' output-format='xml-platform' version='1.0'>
    		<entity name='new_building'>
    			<attribute name='new_buildingid'/>
    			<attribute name='new_name'/>
    			<attribute name='new_providerid'/>
    			<attribute name='new_address1_line1'/>
    			<attribute name='new_address1_line2'/>
    			<attribute name='new_address1_line3'/>
    			<attribute name='new_address1_city'/>
    			<attribute name='new_address1_stateorprovince'/>
    			<attribute name='new_address1_postalcode'/>
    			<attribute name='new_lowersize'/>
    			<attribute name='new_uppersize'/>
    			<attribute name='new_costlower'/>
    			<attribute name='new_costhigher'/>
    			<attribute name='new_latitude' />
    			<attribute name='new_longitude' />
    			<attribute name='new_managedofficespace'/>
    			<attribute name='new_servicedoffice'/>
    			<attribute name='new_coworkingspace'/>
    			<attribute name='new_virtualoffices'/>
    			<attribute name='new_leasedoffice'/>
    			<attribute name='new_buildingdescription'/>
    			<attribute name='new_locationdescription'/>
    			<attribute name='new_nearesttube'/>
    			<link-entity name='po_powerphoto' from='po_oid' to='new_buildingid' link-type='outer' alias='pp'>
    				<attribute name='po_powerphotoid'/>
    				<attribute name='po_oid'/>
    				<attribute name='po_defaultimage'/>
    				<order attribute = 'po_oid' descending='true'/>
    				<order attribute = 'po_defaultimage' descending = 'true' />
    				<filter type='and'>
    					<condition attribute='po_defaultimage' value='1' operator='eq'/>
    				</filter>
    			</link-entity>
    			<filter type='and'>".$spacefilter.$facfilter."
    				<condition attribute='statecode' value='0' operator='eq'/>
    				<condition attribute='new_latitude' value='".$lat1."' operator='ge'/>
    				<condition attribute='new_latitude' value='".$lat2."' operator='le'/>
    				<condition attribute='new_longitude' value='".$lng1."' operator='ge'/>
    				<condition attribute='new_longitude' value='".$lng2."' operator='le'/>
    				<filter type='or'>
    					<filter type='and'>
    						<filter type='or'>
    							<condition attribute='new_lowersize' value='".$low."' operator='le'/>
    							<condition attribute='new_lowersize' operator='null'/>
    						</filter>
    						<filter type='or'>
    							<condition attribute='new_uppersize' value='".$low."' operator='ge'/>
    							<condition attribute='new_uppersize' operator='null'/>
    						</filter>
    					</filter>
    					<filter type='and'>
    						<filter type='or'>
    							<condition attribute='new_lowersize' value='".$high."' operator='le'/>
    							<condition attribute='new_lowersize' operator='null'/>
    						</filter>
    						<filter type='or'>
    							<condition attribute='new_uppersize' value='".$high."' operator='ge'/>
    							<condition attribute='new_uppersize' operator='null'/>
    						</filter>
    					</filter>
    				</filter>
    			</filter>
    		</entity>
    	</fetch>
    	{% endblock %}
    	{% block template %}
    		{% spaceless %}
    		{% set previd = null %}
    		{% set nextid = null %}
    		<div id='sortme'>
    			{% for record in records %}
    				{% set nextid = records[loop.index0 + 1].new_buildingid %}
    				{% if record.new_buildingid != previd %}'
    					<div class='result' data-id='{{record.new_buildingid}}' data-location='{{ urlify(record.new_name) }}' data-location-test='{{ record.new_name|e('url') }}' data-lat='{{record.new_latitude}}' data-lng='{{record.new_longitude}}' data-price='{{record.new_costlower}}'>
    							<div class='result-slide'>
    				{% endif %}
    
    				{% if record.pp.po_powerphotoid %}<div class='result-image' style='background-image:url(/wp-admin/admin-ajax.php?action=msdyncrm_image&id={{record.pp.po_powerphotoid}}&width=800);'></div>{% else %}<div class='result-image' style='background-image:url(/wp-content/themes/cornerstone/assets/img/CS_Default-Image.png);'></div>{% endif %}
    
    				{% if record.new_buildingid != nextid %}
    							</div>
    							<div class='result-content'>
    								<div class='result-text'>
    									<h2>{{record.new_name}}</h2>
    									<h3>{{record.new_address1_line3}}{% if record.new_address1_line3 and record.new_address1_city %}, {% endif %}{{record.new_address1_city}}</h3>
    									<p>{{record.new_buildingdescription[:125]}}{% if record.new_buildingdescription %}...{% endif %}</p>
    								</div>
    								<div class='result-details'>
    									<div class='row'>
    										<div class='category {% if record.new_managedofficespace == 1 %}category-flexiblemanaged{% elseif record.new_servicedoffice == 1  %}category-servicedoffice{% elseif record.new_coworkingspace == 1  %}category-co-working{% elseif record.new_virtualoffices == 1  %}category-virtualoffice{% elseif record.new_leasedoffice == 1  %}category-leasedoffice{% endif %}'>
    											<p>{% if record.new_managedofficespace == 1 %}Flexible Managed{% elseif record.new_servicedoffice == 1  %}Serviced Office{% elseif record.new_coworkingspace == 1  %}Co-Working{% elseif record.new_virtualoffices == 1  %}Virtual Office{% elseif record.new_leasedoffice == 1  %}Leased Office{% endif %}</p>
    											<div class='result-info'>
    												<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 19.94 19.94'><path d='M10,19.94a10,10,0,1,1,10-10A10,10,0,0,1,10,19.94ZM10,1a9,9,0,1,0,9,9A9,9,0,0,0,10,1ZM7.37,6.08a4.71,4.71,0,0,1,.5-.39,3.74,3.74,0,0,1,.59-.33,3.57,3.57,0,0,1,.69-.22A3.77,3.77,0,0,1,10,5.05,3.33,3.33,0,0,1,11,5.22a2.46,2.46,0,0,1,.84.47,2.18,2.18,0,0,1,.55.73,2.27,2.27,0,0,1,.2,1,2.48,2.48,0,0,1-.16.93A2.59,2.59,0,0,1,12,9a3.13,3.13,0,0,1-.53.51L11,9.92a3.75,3.75,0,0,0-.43.38.76.76,0,0,0-.22.42l-.14,1.07H9.25l-.1-1.17a.87.87,0,0,1,.11-.57,2,2,0,0,1,.39-.45,5.44,5.44,0,0,1,.53-.41,4,4,0,0,0,.54-.44,2.39,2.39,0,0,0,.42-.55,1.5,1.5,0,0,0,.17-.73,1.19,1.19,0,0,0-.11-.53,1.2,1.2,0,0,0-.31-.4,1.39,1.39,0,0,0-.47-.26,1.82,1.82,0,0,0-.57-.09,2.23,2.23,0,0,0-.72.1,3,3,0,0,0-.51.22,3.34,3.34,0,0,0-.34.22.41.41,0,0,1-.23.1.31.31,0,0,1-.3-.18Zm1.38,8.46a.93.93,0,0,1,.56-.86.91.91,0,0,1,.37-.07.89.89,0,0,1,.36.07,1,1,0,0,1,.5.5.89.89,0,0,1,.07.36.91.91,0,0,1-.07.37,1,1,0,0,1-.2.3.9.9,0,0,1-.3.2.93.93,0,0,1-.36.07,1,1,0,0,1-.37-.07A.87.87,0,0,1,9,15.2a.93.93,0,0,1-.19-.3A1,1,0,0,1,8.75,14.53Z' transform='translate(0 0)'/></svg>
    												<div class='tooltip-info'>{% if record.new_managedofficespace == 1 %}A managed office allows you to have a bespoke fit-out and arrange your own IT and telecoms, but in a fairly flexible manner in relation to contract commitment. One operator will take care of all elements including moving in and out, customisation and making sure the space fits your business needs.{% elseif record.new_servicedoffice == 1  %}'The full package’ option with negotiable contract length. A serviced office is your one-stop shop for a dedicated and private office for your company and come with internet and telecoms within the offering. For short or longer term arrangements, serviced offices offer a flexible but professional feel that allows growth and in an ever-changing business climate.{% elseif record.new_coworkingspace == 1  %}Ideal for sole traders, start-ups and those who just thrive on collaboration; co-working space provides you with a hot-desk or designated bank of desks within a building that incorporates other businesses. A straightforward option where you can rock up with a laptop and just get stuff done without the commitment of an entire office.{% elseif record.new_virtualoffices == 1  %}A great option for those who don’t yet need a work space, or for businesses that don’t require a base. A virtual office will provide a prestigious registered address where mail can be sent and organised, a telephone number and call answering or forwarding services, plus offer business facilities should you need them.{% elseif record.new_leasedoffice == 1  %}A leased office is the business version of buying a house. Similar to a mortgage, you will have a long term loan on the property (leases are for contract terms of 5 years+) and be solely in charge of what goes on under its roof. A leased option is perfect for established companies who are relatively stable in terms of growth and location.{% endif %}</div>
    											</div>
    										</div>
    										<div data-id='{{record.id}}' class='featured-shortlist'></div>
    									</div>
    									<div class='row'>
    										<ul>
    											<li>{{record.new_lowersize}} - {{record.new_uppersize}}</li>
    											<li>{% if record.new_costlower %}From £{{record.new_costlower}}{% else %}£POA{% endif %}</li>
    										</ul>
    									</div>
    									<div class='row'>
    										<div class='tube'>
    											<p>{{record.new_nearesttube}}</p>
    										</div>
    									</div>
    								</div>
    							</div>
    						</div>
    				{% endif %}
    				{% set previd = record.new_buildingid %}
    			{% endfor %}
    		</div>
    	{% endspaceless %}
    	{% endblock %}
    [/msdyncrm_inline]"); ?>
    Jon Brain

    (@brainjonbrain)

    The problem I have replicating the query using [msdyncrm_twig], is that I can’t get the fetchxml command to work.

    In [msdyncrm_inline] I could use {% block fetchxml %}, but with [msdyncrm_twig] I seem to need to use {% fetchxml %}. However, the {% fetchxml %} command appears to need a “collection” attribute, and I don’t have one – I just want to query all of my data. How do I do that? The docs are very light in this area.

    Thanks,
    Jon

    Jon Brain

    (@brainjonbrain)

    OK, success!

    I fathomed what I was doing wrong with the fetchxml construct, and can confirm my custom function now works. Using [msdyncrm_twig] instead of the deprecated [msdyncrm_inline] shortcode was the answer all along.

    Many thanks for your time and assistance!

    Jon

    Plugin Author alexacrm

    (@alexacrm)

    Great to hear, Jon, thank you for your patience.
    We’ll be publishing a guide how to extend twig at some point in the future but looks like you’ve got it under control now.
    George

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘How can I add a function to Twig?’ is closed to new replies.