<?php if ($zutu) { $key=0; foreach ($zutu as $c) { ?>
{
{php $cc = current($zutu);}
href: "{dr_get_file($cc)}",
src: "{dr_get_file($c)}",
img: "{dr_get_file($c)}",
width: "237", height: "150",
title: "{$t['title']}"
},
<?php $key++;} } ?>我想調(diào)用該圖片的寬度的數(shù)值,寫成100%和auto都不行,系統(tǒng)里有沒有這個變量可以調(diào)出來?
<?php $size = getimagesize(dr_get_file($c)); ?> width: "{$size[0]}", height: "{$size[1]}",你這又是用循環(huán)又是用單一輸出,思維太混了,影響頁面速度啊
開源是一種精神,但不是義務,幫忙是情分,不幫也不要抱怨,建議大家多研究代碼、多閱讀代碼、多翻閱社區(qū)歷史問題!
回復@迅睿框架聯(lián)合創(chuàng)始人
<?php if ($zutu) { $key=0; foreach ($zutu as $c) { ?> { index: {$key+1}, href: "{dr_get_file($c)}", src: "{dr_get_file($c)}", img: "{dr_thumb($c, 200, 200)}", {php $size = getimagesize(dr_thumb($c)); } width: "{$size[0]}", height: "150", title: "{$t['title']}" }, <?php $key++;} } ?>調(diào)出來了,感謝大神,確實現(xiàn)在這個代碼的執(zhí)行效率太慢,頁面打開明顯慢多了,怎么優(yōu)化一下速度呢?
<?php if ($zutu) { $key=0; foreach ($zutu as $c) { ?> { index: {$key+1}, href: "{dr_get_file($c)}", src: "{dr_get_file($c)}", img: "{dr_thumb($c, 200, 200)}", {php $at=$ci->get_attachment($c);if ($at && $at.attachinfo) { $size=[$at['attachinfo']['width'], $at['attachinfo']['height']];} { $size = getimagesize(dr_get_file($c))}; } width: "{$size[0]}", height: "150", title: "{$t['title']}" }, <?php $key++;} } ?>回復@小波工作室 這個代碼執(zhí)行出現(xiàn)系統(tǒng)故障! 但是我找不出錯在哪里?
回復@小波工作室
FCPATH/App/Module/Extends/Home/Module.php : 510 — Phpcmf\View->display ( arguments )
503 'params' => ['catid' => $catid],
504 'parent' => $parent,
505 'related' => $related,
506 'urlrule' => \Phpcmf\Service::L('Router')->show_url($this->module, $data, '[page]'),
507 'fix_html_now_url' => defined('SC_HTML_FILE') ? dr_url_prefix(\Phpcmf\Service::L('Router')->show_url($this->module, $data, $page), $this->module['dirname'], SITE_ID, \Phpcmf\Service::IS_MOBILE_TPL()) : '', // 修復靜態(tài)下的當前url變量
508 ]);
509 \Phpcmf\Service::V()->module($this->module['dirname']);
510 !$rt && (\Phpcmf\Service::V()->display(isset($data['template']) && strpos($data['template'], '.html') !== FALSE && is_file(\Phpcmf\Service::V()->get_dir().$data['template']) ? $data['template'] : ($this->module['category'][$data['catid']]['setting']['template']['show'] ? $this->module['category'][$data['catid']]['setting']['template']['show'] : 'show.html')));
511 return $data;
512 }
513
514 // 模塊草稿、審核、定時、內(nèi)容頁
515 protected function _MyShow($type, $id = 0, $page = 1) {
516
517 if (IS_POST) {
APPPATH/Controllers/Show.php : 23 — Phpcmf\Home\Module->_Show ( arguments )
16 }
17 $this->_Show(
18 (int)$id,
19 [
20 'field' => dr_safe_replace(\Phpcmf\Service::L('Input')->get('field')),
21 'value' => dr_safe_replace(\Phpcmf\Service::L('Input')->get('value')),
22 ],
23 max(1, (int)\Phpcmf\Service::L('Input')->get('page'))
24 );
25 }
26
27 public function time() {
28 $this->_module_init();
29 $this->_MyShow(
30 'time',
SYSTEMPATH/CodeIgniter.php : 832 — Phpcmf\Controllers\Show->index ()
825 {
826 // If this is a console request then use the input segments as parameters
827 $params = defined('SPARKED') ? $this->request->getSegments() : $this->router->params();
828
829 if (method_exists($class, '_remap')) {
830 $output = $class->_remap($this->method, ...$params);
831 } else {
832 $output = $class->{$this->method}(...$params);
833 }
834
835 $this->benchmark->stop('controller');
836
837 return $output;
838 }
839
SYSTEMPATH/CodeIgniter.php : 419 — CodeIgniter\CodeIgniter->runController ( arguments )
412 if (! method_exists($controller, '_remap') && ! is_callable([$controller, $this->method], false)) {
413 throw PageNotFoundException::forMethodNotFound($this->method);
414 }
415
416 // Is there a "post_controller_constructor" event?
417 Events::trigger('post_controller_constructor');
418
419 $returned = $this->runController($controller);
420 } else {
421 $this->benchmark->stop('controller_constructor');
422 $this->benchmark->stop('controller');
423 }
424
425 // If $returned is a string, then the controller output something,
426 // probably a view, instead of echoing it directly. Send it along
SYSTEMPATH/CodeIgniter.php : 326 — CodeIgniter\CodeIgniter->handleRequest ( arguments )
319 $this->response->pretend($this->useSafeOutput)->send();
320 $this->callExit(EXIT_SUCCESS);
321
322 return;
323 }
324
325 try {
326 return $this->handleRequest($routes, $cacheConfig, $returnResponse);
327 } catch (RedirectException $e) {
328 $logger = Services::logger();
329 $logger->info('REDIRECTED ROUTE at ' . $e->getMessage());
330
331 // If the route is a 'redirect' route, it throws
332 // the exception with the $to as the message
333 $this->response->redirect(base_url($e->getMessage()), 'auto', $e->getCode());
FCPATH/Fcms/Init.php : 523 — CodeIgniter\CodeIgniter->run ()
516 $env = new DotEnv(COREPATH);
517 $env->load();
518
519 helper('url');
520
521 $app = new \Phpcmf\Extend\CodeIgniter(new App());
522 $app->initialize();
523 $app->run();
回復@游子2018 試試這樣寫
<?php if($zutu) { $key=0; foreach($zutu as $c) { ?> { index: {$key+1}, href: "{dr_get_file($c.file)}", src: "{dr_get_file($c.file)}", img: "{dr_thumb($c.file, 200, 200)}", <?php $at = $ci->get_attachment($c.file); if ($at && $at.attachinfo) { $size=[$at['attachinfo']['width'], $at['attachinfo']['height']]; } else { $size = getimagesize(dr_get_file($c.file)); } ?> width: "{$size[0]}", height: "{$size[1]}", title: "{$t['title']}" }, <?php $key++; } } ?>