组的Codeigniter自定义元描述

时间:2018-10-24 18:15:59

标签: codeigniter

首先对这个问题感到抱歉,我对php并不熟悉,但是我花了4天的时间来努力学习类似的威胁,现在我需要您的帮助:

我已经购买了一个使用codeigniter创建的网站,该网站的 global site_head定义如下:

<meta name="DESCRIPTION" content="<?=$description?>">

,然后将描述变量替换为帖子的标题-用于组(类别)和单个页面。

我已使用php我的管理员在组(类别)表中创建了其他行-称为“ my_meta_desc” 输入<?=$group['my_meta_desc']?>时在视图文件夹中-我的元描述正在按原样显示,但是我只有my_meta_desc用于类别,如果我替换

<meta name="DESCRIPTION" content="<?=$description?>">

<meta name="DESCRIPTION" content="<?=$group['my_meta_desc']?>">

除类别外,所有页面的描述将为空白。

是否可以使用一些函数-定义是否使用groups / images.php(这是一个视图文件)来使用<?=$group['my_meta_desc']?>以及其他所有<?=$description?>- site_head.php吗?


根据我的研究,描述是在models文件夹下的template.php模型文件中定义的:

    if(empty($desc)) $desc = $site_info['meta_description'];
    $data['description'] = $desc;

$ site_info ['meta_description']-是索引页面的元描述,仅在此处使用(当然,所有页面都没有元描述)

我只是找不到$ desc的定义位置-有任何线索吗? -因为正如我已经为单页说明的那样,元描述是帖子标题-包含在数据库表中-'图像'行' text ',对于类别,它位于数据库中表' groups '行' name '

有一个组控制器,但不包含与$ desk或$ description相关的任何内容。

任何建议,我都会感谢

Template.php-位于模型文件夹中:

   function Load($file,$data,$title,$type='public',$desc='',$block_index=0){
    global $admin_row, $user_row, $lang_array, $l, $lf, $site_info, $sidebar_groups_inc;

    if(!isset($sidebar_groups_inc)){
        $sidebar_groups_inc = array();
    }
    $data['sidebar_groups'] =  $sidebar_groups_inc;

    if($type == 'admin'){
        $title = "Админ Панел - ".$title;
    }

    if($type == 'public'){
        $languages = $lang_array;

        $data['languages'] = $languages;

        if($user_row['login'] == 1){
            $data['nf_header']=array();
            $get = imysql_adapted_query("select notifications.*, timediff(concat(curdate(), ' ', curtime()), concat(date)) as hours from notifications where user = '".$user_row['id']."' order by `read` asc, id desc limit 0,5");
            if($get){
                while($row = imysql_adapted_fetch_array($get)){
                    $data['nf_header'][] = $row;
                }
            }

            foreach($data['nf_header'] as $val){
                if($val['read'] == 0) {
                    $data['mark_notifications'][] = $val['id'];
                }
            }

        }

        $data['pages']=array();
        $get_pages = imysql_adapted_query("select id, name_".$lf." as name from pages where cat = '3' order by id asc");
        if($get_pages){
            while($row = imysql_adapted_fetch_array($get_pages)) {
                $data['pages'][] = $row;
            }
        }

    }

    $data['title'] = $this->Title($title);
    $data['file'] = $type."/".$file;
    $data['admin'] = $admin_row;
    $data['user'] = $user_row;
    //      $data['path'] = $data['path'];

    if(empty($key)) $key = $site_info['meta_keywords'];

    if(empty($desc)) $desc = $site_info['meta_description'];
    $data['description'] = $desc;
    $data['keywords'] = $key;
    $data['block_index'] = $block_index;



    $data['data'] = $data; // TODO: Fix the need for this shitty reference !!!
    $this->load->view($type.'/site_head',$data);

2 个答案:

答案 0 :(得分:0)

只需:

@Injectable()
export class MeasurementService {
    loadTrigger$ = new Subject();
    measurements$ = new Subject<Measurement[]>();
    currentMeasurements: Measurement[] = [];

    beginDate: Date;
    nextlinkFormat: string = 'http://myapi?type=TYPEID';
    nextlink: string;

    constructor(private http: HttpClient) { }

    public getMeasurements(typeId: TypeId): Observable<Measurement[]> {
        console.info('MeasurementService.getMeasurements()', pollInterval);
        this.nextlink = this.nextlinkFormat
            .replace('TYPEID', typeId.toString())

        this.currentMeasurements = [];

        timer(0, pollInterval)
            .subscribe(x => this.loadTrigger$.next());

        this.loadTrigger$.pipe(
            map(x => this.http.get(this.nextlink)),
        )
            .subscribe((response) => {
                response.pipe(map((response) => response as MeasurementsDto)).
                    subscribe(
                        measurementsDto => {
                            let newMeasurements = measurementsDto.measurements.map(Measurement.fromMeasurementDto);
                            this.currentMeasurements.push.apply(this.currentMeasurements, newMeasurements);

                            this.nextlink = measurementsDto.nextlink;
                            if (newMeasurements.length > 0) {
                                console.log(newMeasurements.length + " new items");
                                this.loadTrigger$.next();
                                this.measurements$.next(this.currentMeasurements);
                            }
                        });
            });

        return this.measurements$.asObservable();
    }
}

答案 1 :(得分:0)

最后我想通了:

<meta name="DESCRIPTION" content="<meta name="DESCRIPTION" content="<? if($groups){  echo  $group['my_meta_desc'];
     } else {
      echo $description;} ?>">