歡迎光臨, 訪客. 請先 登入註冊一個帳號.
四月 28, 2024, 12:24:11 下午
19595 文章 在 3865 主題 由 4580 會員
最新註冊會員: aa123aa1
LifeType 中文開發論壇  |  開發  |  外掛程式  |  大大门,求救啊~~~~ « 上篇主題 下篇主題 »
頁: [1]
作者 主題: 大大门,求救啊~~~~  (閱讀 12146 次)
netflu
新手見習
*
文章: 3


檢視個人資料
« 於: 七月 24, 2006, 04:40:51 下午 »

我使用的是LifeType1.0.5,现需要实现一个功能,就是在回复栏里面,当用户是已登陆状态时,读取此用户的用户名并在"用户名输入框"中显示出来。
程序取得用户名并显示这些都没问题,问题是:好像是因为Samrt模板缓存了页面的原因,数据只会取一次,那么用户换了其它帐号登陆后,页面上显示的还是之前的用户名,不知道有没什么解决方法?


以下是我修改的代码,方便大家测试:
/*
 修改 class/view/blogview.class.php 类的
*/
首先在头部加上:
include_once( PLOG_CLASS_PATH."class/net/http/session/sessionmanager.class.php" );


然后修改render()方法,红色部分为新加代码:

      function render()
      {      
         if( !$this->isCached()) {
            // and then add our stuff to the view...
            $this->setValue( 'archives', $this->_getArchives());
            $this->setValue( 'recentposts', $this->_getRecentPosts());
            $this->setValue( 'mylinkscategories', $this->_getLinkCategories());
            $this->setValue( 'monthposts', $this->_getMonthPosts());
            $this->setValue( 'articlecategories', $this->_getArticleCategories());
            $this->generateCalendar( $this->getValue( 'Year' ), $this->getValue( 'Month' ));
            
            // also, let's not forget about the plugins...
            // put the plugins in the context
            $plugins = $this->_pm->getPlugins();
            foreach( $plugins as $name => $plugin ) {
               $this->setValue( $name, $plugin );
            }
         }

         //
         // these things can go in since they do not mean much overhead when generating the view...
         //
         $this->setValue( 'locale', $this->_blogInfo->getLocale());         
         $this->setValue( 'version', Version::getVersion());
         $this->setValue( 'now', new Timestamp());         
         $this->setValue( 'blog', $this->_blogInfo );         
         $this->setValue( 'url', $this->_blogInfo->getBlogRequestGenerator());
         $this->setValue( 'utils', $this->_blogInfo->getBlogRequestGenerator());
         $this->setValue( 'blogsettings', $this->_blogInfo->getSettings());
         $this->setValue( 'rss', new RssParser());

         $session = HttpVars::getSession();
         $sessionInfo = $session["SessionInfo"];
         $userInfo = $sessionInfo->getValue( "userInfo" );
         if ( $userInfo == "" ) {
             $this->setValue( 'myname', "anonymous");
         }
         else {
             $this->setValue( 'myname', $userInfo->getUsername());
         }


         
         
         // ask the parent to do something, if needed
         parent::render();
      }




/*
  修改任何模板的 commentform.template
*/

<input type="text" name="commentTopic" value=""/>

<input type="text" name="commentTopic" value="{$myname}"/>



大家帮忙看看有没什么解决方法,thanks~~
« 最後編輯時間: 七月 24, 2006, 05:08:39 下午 由 netflu » 已記錄
james
LifeType 中文發展團隊
超級會員
*****
文章: 823


哼!!你不說,誰會知道你做過那些修改呢!? (丟滑鼠~~)


檢視個人資料 個人網站
« 回覆文章 #1 於: 七月 24, 2006, 04:47:22 下午 »

將快取關閉. 微笑

James.
已記錄

記得發問前,先使用搜尋功能找找看有沒相關的解答。
如果找不到,請依照如何在LifeType論壇發問來提問喔。
netflu
新手見習
*
文章: 3


檢視個人資料
« 回覆文章 #2 於: 七月 24, 2006, 04:49:16 下午 »

將快取關閉. 微笑

James.


有点望说了,偶不懂 Smart,所以怎么关快取,麻烦详细说说, 吐舌頭
已記錄
james
LifeType 中文發展團隊
超級會員
*****
文章: 823


哼!!你不說,誰會知道你做過那些修改呢!? (丟滑鼠~~)


檢視個人資料 個人網站
« 回覆文章 #3 於: 七月 24, 2006, 04:55:18 下午 »

我說的是把LT中的系統快取關閉:)
請到後台的全部站台管控中的模版設定
將template_cache_enabled 設為否
template_http_cache_enabled 一樣設為否.
看看會不會有效果囉^_^

James.
已記錄

記得發問前,先使用搜尋功能找找看有沒相關的解答。
如果找不到,請依照如何在LifeType論壇發問來提問喔。
netflu
新手見習
*
文章: 3


檢視個人資料
« 回覆文章 #4 於: 七月 24, 2006, 05:09:44 下午 »

我說的是把LT中的系統快取關閉:)
請到後台的全部站台管控中的模版設定
將template_cache_enabled 設為否
template_http_cache_enabled 一樣設為否.
看看會不會有效果囉^_^

James.


OK, 搞定了,呵呵,冰天雪地跪谢:)
已記錄
james
LifeType 中文發展團隊
超級會員
*****
文章: 823


哼!!你不說,誰會知道你做過那些修改呢!? (丟滑鼠~~)


檢視個人資料 個人網站
« 回覆文章 #5 於: 七月 24, 2006, 06:51:02 下午 »

OK, 搞定了,呵呵,冰天雪地跪谢:)
不客氣囉^_^
James.
已記錄

記得發問前,先使用搜尋功能找找看有沒相關的解答。
如果找不到,請依照如何在LifeType論壇發問來提問喔。
markwu
系統管理員
超級會員
*****
文章: 3928


Mark Wu


檢視個人資料 個人網站
« 回覆文章 #6 於: 七月 25, 2006, 03:09:30 上午 »

你要作什麼用呢?如果是要給多人使用,你關掉 cache 後付出的代價更大。

把 session 轉成 cookie, 然後用 javascript 讀取 cookie 內的值,再用 docuement.write  寫到 html 中才是比較好的方式。

Mark
已記錄

頁: [1]
LifeType 中文開發論壇  |  開發  |  外掛程式  |  大大门,求救啊~~~~ « 上篇主題 下篇主題 »
    前往: