• Resolved lwbenso

    (@lwbenso)


    I am trying to understand the twig templates found on the AlexaCRM support page. My goal is to display account names from Dynamics on my website and remove the column headers; I believe this is possible by specifying the “header” field in the entityview object. I am having trouble understanding how to code this – the example specified on the support page {% view entity="contact" name="Active Contacts" parameters=[ "contoso.com" ] lookups={ "parentcustomerid": params.account "} count="10" cache="PT30M" %}{% endview %} does not include any of the entityview object fields so I’m not sure what it would look like. I’ve tried everything I can think of and am at a dead end. I’m sure that the solution must be simple and that I just am not familiar with this type of coding. Can anyone help?

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

    (@alexacrm)

    Hi @lwbenso

    if you want to remove header then you need to look at custom rendering, i.e. loop through the rows and build the output as you see fit.

    HTH
    AlexaCRM Team

    Plugin Author alexacrm

    (@alexacrm)

    Hi @lwbenso

    more details. Basically if you use view tag then you can specify your own template inside the tag

    {% view %}
    template goes here
    {% endview %}
    

    In the absence of the tag content, the default view is rendered, i.e. https://github.com/AlexaCRM/integration-dynamics/blob/master/templates/twig/view.twig

    Take that view as a template and modify as required, e.g. remove headers, etc.

    HTH
    George

    • This reply was modified 7 years, 1 month ago by alexacrm.
    • This reply was modified 7 years, 1 month ago by alexacrm.
    Thread Starter lwbenso

    (@lwbenso)

    Hi George @alexacrm,

    Thank you for the response. I tried using the template mentioned above and am receiving an error:

    Unexpected error: Unexpected character "&" in "template_57e169ff5c09571f45b7ac817c71e5f5f35d5440" at line 26.

    This is the code that I used:

    [msdyncrm_twig]
    {% view entity="account" name="CompletedAccounts" lookups={ "parentcustomerid": params.account }  cache="PT30M" %}
    {% spaceless %}
    {% if entityview.first_page is not null %}
    <table class="{{ tableClass ?? [ 'table' ]|join( ' ' ) }}">
        <thead class="{{ tableHeaderClass ?? []|join( ' ' ) }}">
        {% block headRow %}
            <tr>
            {% for columnName, column in entityview.columns %}
                {% block headCell %}<th>{{ column.name }}</th>{% endblock %}
            {% endfor %}
            </tr>
        {% endblock %}
        </thead>
        <tbody>
        {% for record in entityview.rows %}
            {% block bodyRow %}
                <tr>
                    {% for columnName in entityview.columns|keys %}
                        {% block bodyCell %}<td>{{ record[columnName].formatted_value|raw }}</td>{% endblock %}
                    {% endfor %}
                </tr>
            {% endblock %}
        {% endfor %}
        </tbody>
        {% if entityview.pages|length > 1 %}
        <tfoot>
        <tr>
          <td colspan="{{ entityview.columns|length }}">
            <nav>
              <ul class="pagination">
                <li class="page-item{% if entityview.previous_page is null %} disabled{% endif %}"><a class="page-link" href="{% if entityview.previous_page %}{{ request.url|add_query('viewPage', entityview.previous_page)}}{% else %}#{% endif %}">Previous</a></li>
                {% for pageNumber in entityview.pages %}
                <li class="page-item{% if pageNumber == entityview.page %} active{% endif %}"><a class="page-link" href="{{ request.url|add_query('viewPage', pageNumber) }}">{{ pageNumber }}</a></li>
                {% endfor %}
                <li class="page-item{% if entityview.next_page is null %} disabled{% endif %}"><a class="page-link" href="{% if entityview.next_page %}{{ request.url|add_query('viewPage', entityview.next_page)}}{% else %}#{% endif %}">Next</a></li>
              </ul>
            </nav>
          </td>
        </tr>
        </tfoot>
        {% endif %}
    </table>
    {% else %}
        {% block noRecords %}
            <p>No records found.</p>
        {% endblock %}
    {% endif %}
    {% endspaceless %}
    
    {% endview %}
    [/msdyncrm_twig]
    • This reply was modified 7 years, 1 month ago by lwbenso.
    Plugin Author alexacrm

    (@alexacrm)

    Hi @lwbenso,

    sorry for the delayed reply – didn’t get notification about your reply o__O.

    It looks like some of your values contain ‘&’. Though twig output is escaped automatically, you are using raw filter:

    {% block bodyCell %}<td>{{ record[columnName].formatted_value|raw }}</td>{% endblock %}

    Try removing this filter and see if error disappears.

    HTH
    George
    AlexaCRM Team

    `

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Specificying parameters in the entityview object’ is closed to new replies.