Guest User

Untitled

a guest
Jan 20th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.64 KB | None | 0 0
  1. preg_match_all("/\{\{[a-z0-9]{1}([a-z0-9\_]*[a-z0-9]{1})?\}\}/", $content_new, $custom_attrs);
  2.                                 if(count($custom_attrs[0]) > 0){
  3.                                     foreach($custom_attrs[0] as $custom_attr){
  4.                                         $custom_attr_trim = trim($custom_attr,"\}\{");
  5.                                         $mdb->select("contacts_attr_options.value");
  6.                                         $mdb->from("contacts_attr");
  7.                                         $mdb->join("contacts_attr_options", "contacts_attr_options.attr_id = contacts_attr.id");
  8.                                         $mdb->where("contacts_attr.code", $custom_attr_trim);
  9.                                         $mdb->where("contacts_attr_options.contacts_id", $row_info->id);
  10.                                         $query_attr = $mdb->get();
  11.                                         if($query_attr->num_rows() > 0){
  12.                                             $row_attr = $query_attr->last_row();
  13.                                             $content_new = str_replace($custom_attr, $row_attr->value, $content_new);
  14.                                         }else{
  15.                                             $mdb->select("*");
  16.                                             $mdb->from("contacts_attr");
  17.                                             $mdb->where("code", $custom_attr_trim);
  18.                                             $query_attr = $mdb->get();
  19.                                             if($query_attr->num_rows() > 0){
  20.                                                 $row_attr = $query_attr->last_row();
  21.                                                 $content_new = str_replace($custom_attr, $row_attr->default_value, $content_new);
  22.                                             }else{
  23.                                                 if(isset($row_info_arr[$custom_attr_trim])){
  24.                                                     $content_new = str_replace($custom_attr, $row_info_arr[$custom_attr_trim], $content_new);
  25.                                                 }
  26.                                             }
  27.                                         }
  28.                                     }
  29.                                 }
  30.                                 $content_new = str_replace(
  31.                                     array(
  32.                                         "{{firstname}}",
  33.                                         "{{lastname}}",
  34.                                         "{{email}}"
  35.                                     ),
  36.                                     array(
  37.                                         $row_info->firstname,
  38.                                         $row_info->lastname,
  39.                                         $row_info->email
  40.                                     ),
  41.                                     $content_new
  42.                                 );
Add Comment
Please, Sign In to add comment