0
我使用Kirby CMS並創建一個小片段,它通過帖子限制他們是什麼號碼,以及他們是什麼日期。一種基本上創建「autopost」系統的方法。php變量與網站寬範圍
$today = new DateTime("now"); //Declare today
$startdate = new DateTime("2013-09-12"); //Declare startdate
$interval = $startdate->diff($today); //Find the difference between startdate & today
$latest = $interval->format('%a'); //Declare $latest variable to be that interval, formatted as integer
所以我有它創建我的$latest
變量,然後我就可以用它來控制所顯示的帖子點點。
我的問題是,我不想在每個不同類型的頁面模板上都更改我的$startdate
,所以我想以某種方式使其在整個站點範圍內。
我試圖把它作爲一個片段與柯比的snippet()
函數,但不起作用。我想,片段已經運行後,必須將片段帶入頁面。
如何讓我的代碼段適用於我的整個網站?
你可以嘗試把它放在你的文件系統中。編寫一個代碼,將startdate寫入文件,並在需要時從該文件中獲取它。 ? – Shoogle