Post by psytanium » Sun Oct 13, 2019 4:19 pm

Hello,

Im not sure if I can find and add after multiple lines using VQMOD, I need some explanation :-\

Can someone tell me why this isn't working :

Code: Select all

<operation error="skip">
            <search position="after"><![CDATA[<td class="text-right"><a href="{{ user.edit }}" data-toggle="tooltip" title="{{ button_edit }}" class="btn btn-primary"><i class="fa fa-pencil"></i></a></td>
                </tr>]]></search>
            <add><![CDATA[{% endif %}]]></add>
        </operation>
The file is admin/view/template/user/user_list. twig
Last edited by psytanium on Sun Oct 13, 2019 8:30 pm, edited 2 times in total.

Active Member

Posts

Joined
Fri Nov 27, 2015 2:07 am

Post by cyclops12 » Sun Oct 13, 2019 5:35 pm

There is no admin/view/template/user/user.twig

Expert Member

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by psytanium » Sun Oct 13, 2019 6:02 pm

cyclops12 wrote:
Sun Oct 13, 2019 5:35 pm
There is no admin/view/template/user/user.twig
User_list.twig

Active Member

Posts

Joined
Fri Nov 27, 2015 2:07 am

Post by cyclops12 » Sun Oct 13, 2019 6:42 pm

You cant search for multiple lines using vqmod/ocmod
You would have to search one line then use offset to go either side of searched line.
This may help you work out how to use vqmod

What are you trying to achieve ?

Expert Member

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by psytanium » Sun Oct 13, 2019 8:28 pm

cyclops12 wrote:
Sun Oct 13, 2019 6:42 pm
You cant search for multiple lines using vqmod/ocmod
You would have to search one line then use offset to go either side of searched line.
This may help you work out how to use vqmod

What are you trying to achieve ?
I'm trying to change this code in user_list.twig

Code: Select all

{% for user in users %}
<tr>
        <td class="text-center">
        {% if user.user_id in selected %}
                <input type="checkbox" name="selected[]" value="{{ user.user_id }}" checked="checked" />
        {% else %}
                <input type="checkbox" name="selected[]" value="{{ user.user_id }}" />
        {% endif %}
        </td>
        <td class="text-left">{{ user.username }}</td>
        <td class="text-left">{{ user.status }}</td>
        <td class="text-left">{{ user.date_added }}</td>
        <td class="text-right"><a href="{{ user.edit }}" data-toggle="tooltip" title="{{ button_edit }}" class="btn btn-primary"><i class="fa fa-pencil"></i></a></td>
</tr>
{% endfor %}
to this

Code: Select all

{% for user in users %}

{% if user.username == "anyone" %}  <-- I want to add this

<tr>
        <td class="text-center">
        {% if user.user_id in selected %}
                <input type="checkbox" name="selected[]" value="{{ user.user_id }}" checked="checked" />
        {% else %}
                <input type="checkbox" name="selected[]" value="{{ user.user_id }}" />
        {% endif %}
        </td>
        <td class="text-left">{{ user.username }}</td>
        <td class="text-left">{{ user.status }}</td>
        <td class="text-left">{{ user.date_added }}</td>
        <td class="text-right"><a href="{{ user.edit }}" data-toggle="tooltip" title="{{ button_edit }}" class="btn btn-primary"><i class="fa fa-pencil"></i></a></td>
</tr>
                
 {% endif %}  <-- I want to add this
                
{% endfor %}
If VQMOD cannot search 2 lines, this mean I cannot find and add after this

Code: Select all

<td class="text-right"><a href="{{ user.edit }}" data-toggle="tooltip" title="{{ button_edit }}" class="btn btn-primary"><i class="fa fa-pencil"></i></a></td>
</tr>
But I can find and replace this

Code: Select all

<td class="text-right"><a href="{{ user.edit }}" data-toggle="tooltip" title="{{ button_edit }}" class="btn btn-primary"><i class="fa fa-pencil"></i></a></td></tr>
Thank you for the support

Active Member

Posts

Joined
Fri Nov 27, 2015 2:07 am

Post by psytanium » Sun Oct 13, 2019 8:50 pm

I used index=2 in the search command, it worked, I searched for the second {% endif %}, but what if another extension or I added a 3rd {% endif %} in between. You think I should another find way of find and add ?

Active Member

Posts

Joined
Fri Nov 27, 2015 2:07 am

Post by cyclops12 » Sun Oct 13, 2019 10:20 pm

Entirely up to you but i would probably search for code that isnt repeated if possible
something like

Code: Select all

<operation error="log">
            <search position="after"><![CDATA[{% for user in users %}]]></search>
            <add><![CDATA[{% if user.username == "YOUR_ADMIN_NAME" %}]]></add>
        </operation>
        <operation error="log">
            <search position="after" offset="1"><![CDATA[<td class="text-right"><a href="{{ user.edit }}" data-toggle="tooltip" title="{{ button_edit }}" class="btn btn-primary"><i class="fa fa-pencil"></i></a></td>
                ]]></search>
            <add><![CDATA[{% endif %}]]></add>
        </operation>

Expert Member

Posts

Joined
Sun Sep 27, 2015 1:10 am
Who is online

Users browsing this forum: No registered users and 95 guests