Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- preg_match_all("/\{\{[a-z0-9]{1}([a-z0-9\_]*[a-z0-9]{1})?\}\}/", $content_new, $custom_attrs);
- if(count($custom_attrs[0]) > 0){
- foreach($custom_attrs[0] as $custom_attr){
- $custom_attr_trim = trim($custom_attr,"\}\{");
- $mdb->select("contacts_attr_options.value");
- $mdb->from("contacts_attr");
- $mdb->join("contacts_attr_options", "contacts_attr_options.attr_id = contacts_attr.id");
- $mdb->where("contacts_attr.code", $custom_attr_trim);
- $mdb->where("contacts_attr_options.contacts_id", $row_info->id);
- $query_attr = $mdb->get();
- if($query_attr->num_rows() > 0){
- $row_attr = $query_attr->last_row();
- $content_new = str_replace($custom_attr, $row_attr->value, $content_new);
- }else{
- $mdb->select("*");
- $mdb->from("contacts_attr");
- $mdb->where("code", $custom_attr_trim);
- $query_attr = $mdb->get();
- if($query_attr->num_rows() > 0){
- $row_attr = $query_attr->last_row();
- $content_new = str_replace($custom_attr, $row_attr->default_value, $content_new);
- }else{
- if(isset($row_info_arr[$custom_attr_trim])){
- $content_new = str_replace($custom_attr, $row_info_arr[$custom_attr_trim], $content_new);
- }
- }
- }
- }
- }
- $content_new = str_replace(
- array(
- "{{firstname}}",
- "{{lastname}}",
- "{{email}}"
- ),
- array(
- $row_info->firstname,
- $row_info->lastname,
- $row_info->email
- ),
- $content_new
- );
Add Comment
Please, Sign In to add comment