Take a field with content "ABC1234567890"

How can this be trimmed to drop the first three positions to get 1234567890 in views, fields and with field_conditional or a module? Trimming 3 gives ABC and -3 drops the 890 which is both wrong. I'm looking to achieve this without using bespoke php code.

Comments

Snehal Brahmbhatt’s picture

Please follow below steps.

Step 1: Create your view template file like views-view-field--your-fieldname.tpl.php
Advanced -> Other -> Theme : information -> Your Field Name : First Name

Step 2: Put below code in your template file.

<?php  
    $output = substr($output, 3); 
    print $output; 
?>

Hope this helps.

Thanks,
Snehal Brahmbhatt | AddWeb Solution
https://www.drupal.org/user/3147795/track

renatog’s picture

Status: Active » Reviewed & tested by the community

Hi guys, how are you?

I checked and really is possible get the first three positions using substr($string, 3);

Thank you very much for your help @snehaladdweb.

Regards.

renatog’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.