Concrete5ã§pjaxã使ã£ã¦ã¿ããï¼
pjaxã®ã©ã¤ãã©ãªãå¤ãã¦è²ã
ãããããªã£ãã®ã§å°ã触ã£ã¦ããConcrete5ã§è©¦ãã¦ã¿ã¾ããã
é·ãããã MODXãªã³ãªã¼ã«ãªã£ã¦ã¾ããããåãã使ã£ã¦ã¿ããã¨æã£ã¦ãCMSãªã®ã§ãã£ã¨åå¼·ãã¦ã³ã³ãã³ããå¢ããã¦ããããã¨æãã¾ã(â'â¡'â)
- pjaxã¨ã¯ï¼
- åä½ãã¢
- jquery.pjax.jsãã©ã°ã¤ã³ã®ãã¦ã³ãã¼ã
- ãã¼ãã®ä¸ã®ã©ããpjaxé·ç§»ããããèããã
- ãã¼ããã¡ã¤ã«ãç·¨éãã
- ãã¹ããã¦ã¿ããï¼
- ãã©ã¼ã ã使ç¨ãã¦ãããã¼ã¸ã«ã¤ãã¦
pjaxã¨ã¯ï¼
pjaxã¨ã¯Ajaxã§ã³ã³ãã³ããå
¥ãæ¿ããã®ã¨åæã«URLãå¤æ´ãã¦ãããjQueryã®ãã©ã°ã¤ã³ã®ååã§ãã
Githubã®ãããªã¹ã ã¼ãºã§ã¤ã±ã¦ããã¼ã¸é·ç§»ãè¡ãã¾ãã
javascriptã®ãpushStateããªã©ã®æ°ãããã¹ããªã¼é¢æ°ã¨Ajaxããµã¼ãã¼ãµã¤ãã¹ã¯ãªãããçµã¿åããã¦ä½ããã¦ããã®ã§jQueryãã©ã°ã¤ã³ãããªãã¦ãå®è£ ã¯å¯è½ã§ããå®éãã®æè¡ããªãã¨å¼ã°ããã®ãã¯ãããã¾ããããã¨ããããpjaxï¼pushState + ajax = pjaxï¼ã§æµ¸éãã¦ãã¿ããã§ããChromeãFirefoxãIE10以éãªã©ã®ãã©ã¦ã¶ã§åä½ããé対å¿ã®ãã©ã¦ã¶ã§ã¯é常ã®ãã¼ã¸é·ç§»ããã¾ãã
pjaxã®åºæ¬ã«ã¤ãã¦ã¯ãã¡ãã®ãã¼ã¸ã§ãæ¸ãã¦ãã¾ãã®ã§ããã£ããã覧ä¸ããã
åä½ãã¢
ãã¡ãã®ãã¢ãã¼ã¸ã御覧ãã ãããï¼å¥çªã§éãã¾ãï¼
å ±éãã¢ã®ããConcrete5ã§ä½æãããã¼ã¸ã§ã¯ããã¾ãããããããªæãã®åãããã¾ãã
jquery.pjax.jsãã©ã°ã¤ã³ã®ãã¦ã³ãã¼ã
jquery.pjax.js ãã¡ããããã¦ã³ãã¼ãã§ãã¾ããï¼2014.05.19æç¹ã®ææ°çã¯Ver.1.32.9ã§ããï¼
ãã¼ãã®ä¸ã®ã©ããpjaxé·ç§»ããããèããã
pjaxã¯ç´æ¥ãã¼ã¸é·ç§»ãããªãã§ãªã³ã¯å ã®ãã¼ã¸ããajaxã§ã³ã³ãã³ããåå¾ãã¦å¿ è¦ãªé¨åã ããæ¸ãæãã¾ãã
Concrete5ã¯ãããã¼ã®å 容ãå¤ãã£ãããã¼ã¸ã¿ã¤ãããã¼ã¸ã«ãã£ã¦ç°¡åã«å¤æ´ããäºãã§ãã¾ãããä¾ãã°ããã°ãã¼ã¸ã§ã³ã³ãã³ãé¨åã ããæ´æ°ããããã¨ãã¦ã次ã®è¨äºãã©ã®ãã¼ã¸ã¿ã¤ãã使ã£ã¦ãããåãããªãå ´åãããã¾ãããããèæ ®ãã¦ã³ã³ãã³ãé¨åã¨ãµã¤ããã¼ã¯ã²ã¨ã¤ã®ããã¾ãã«ãã¦ãã¾ãã¾ãã
ããããããããã¼ã®ã¡ãã¥ã¼ã¨ç»åé¨åããã¼ã¸ã«ãã£ã¦å¤ããã®ã§ãããé·ç§»ãããæ¹ãããã§ããï¼
ãã¼ããã¡ã¤ã«ãç·¨éãã
ä»åã®èª¬æã¯ããã©ã«ãã§å
¥ã£ã¦ãããã¼ããgreek_yogurtãã使ç¨ãã¾ãã念ã®çºãã¹ãç¨ã«ãã¼ããã©ã«ãã®ãgreek_yogurtãã/themes/ã«ã³ãã¼ãããã©ã«ãã®ååããgreek_yogurt_pjaxããªã©ã«å¤æ´ãã¦ãã£ã¡ã使ç¨ãã¾ãã管çç»é¢ã®ãã¼ãé¸æãããgreek_yogurt_pjaxããé¸æãã¦ããã¾ãã
以é説æã«ãããã¼ããã¡ã¤ã«ã¯ãgreek_yogurt_pjaxããéãã¦ç·¨éãã¦ãã ããã
elements/header.phpãéãã¦ãããã¼é¨åã®CSSã®å¾ãããã«pjaxãèªã¿è¾¼ãã¿ã°ã追å ãã¾ãã
次ã«ãã¡ã¤ã³ã¨ãµã¤ããã¼ãä¸ç·ã«é·ç§»ããããã2ã¤ãå²ãã ã¿ã°ã欲ããã®ã§ãããgreek_yogurtãã«ã¯ãããåå¨ããªãã®ã§æ°ããã¿ã°ã追å ãã¾ãã
elements/header.phpã¨elements/blog_header.phpã®ä¸çªæå¾ã«ä»¥ä¸ã®ã¿ã°ã追å ãã¾ãã
elements/footer.phpã®å
é ã«ä»¥ä¸ã®ãããªè¨è¿°ãããã¾ãããã®ä¸ã«éãã¿ã°ã追å ãã¾ãã 追å ããã¨ä»¥ä¸ã®ããã«ãªãã¾ãã
ä¸å¿ããã§äºåæºåã¯ãããï¼
次ã«elements/header.phpãéãã¦pjaxã®è¨å®ããã¾ããä¸å¿ä»¥ä¸ã¯ãgreek_yogurtãç¨ã«æ¸ãããµã³ãã«ã³ã¼ãã§ãããããã¼ã«ç´æ¥æ¸ãè¾¼ããå¤é¨jsãã¡ã¤ã«ã«ãã¦ãããã¼ã§èªã¿è¾¼ãã§ãã ãããããã¯ãgreek_yogurtãã«å¤§åæé©åãã¦ããã®ã§ä»ã®ãã¼ãã®å ´åIDã®é¨åãä¿®æ£ããå¿ è¦ãããã¾ãã
ã¡ãã£ã¨ããããæ¸ãã¦ãã£ã¦ç·¨éã®ä»æ¹ãåãããªãï¼ã¨ããå ´åã¯ä»¥ä¸ã®ã³ã¼ãã使ç¨ãã¦ã¨ãã§ã¯ãå¦çãªã©ãå°ãã¥ã¤è¿½å ãã¦è¦ã¦ãã ããã(â'â¡'â)
ãã¹ããã¦ã¿ããï¼
ãã¾ãpjaxã§ããããã¹ããã¦ã¿ã¾ãããã念ã®ãã管çç»é¢ã§ãã£ãã·ã¥ãã¯ãªã¢ãã¦ããã«ãã¼ã¸ãã£ãã·ã¥ããªãã«ãã¦ããã¾ãããã¡ãã¨pjaxé·ç§»ãã¦ããã確èªããããelements/header.phpã®å ã«è¿½å ãã#pjaxContentã¿ã°ã®ç´åã«ã¿ã¤ã ã¹ã¿ã³ãã表示ããã¦ããã¾ãã
ãããã¼ç»åã®ä¸ã«æ°åã表示ãããã¨æãã¾ããããã®æ°åã¯ãã«ãã¼ã¸ãã£ãã·ã¥ããã¦ããªããã°ãã¼ã¸ç§»åã®åº¦ã«å¤ããã¾ãããã¼ã¸ç§»åãã¦ã¿ã¦ãã®æ°åã®æ«å°¾ã®æ¹ãå¤åããªããã°pjaxé·ç§»ãã¦ããã¨ãããã¨ã§ããï¼
ãã¾ãæ°åãå¤ãããã«é·ç§»ãã¦ãããããªãæåã§ãã time()ã®é¨åãåé¤ãã¦ãã«ãã¼ã¸ãã£ãã·ã¥ãå ã®è¨å®ã«æ»ãã¦ããã¾ãããã
ã¾ããç§èªèº«Concrete5ãã¾ã ãããªã«ä½¿ãåãã¦ããªãã®ã§å ´åã«ãã£ã¦ãã®æ¹æ³ã¯ä½¿ç¨ã§ããªãããããã¾ããããã©ã¼ã ããã¤ãã¿ã¼ã§ãææããã ããã°åæ ãã¾ãã®ã§æ°è»½ã«ãé£çµ¡ãã ããï¼
ãã©ã¼ã ã使ç¨ãã¦ãããã¼ã¸ã«ã¤ãã¦
ãã©ã¼ã ã¨ã¯éããªãã¨æãã®ã§ããããåãåãããããã°ã®ã³ã¡ã³ããã®ä»ä¸é¨ã®ãããã¯ã使ç¨ãã¦ãããã¼ã¸ã§ã¯pjaxé·ç§»ããå¾ã«é常é·ç§»ãã¦ãã¾ãããã§ãã2éé·ç§»ã«ãªã£ã¦ãã¾ãã®ã§linkãã©ã¡ã¼ã¿ã§.nopjaxãä»ãããªã©å¯¾çãã¦ãã ãããï¼åå ã追ã£ã¦ã¿ããã¨æã£ãã®ã§ããæéããªãã¦æ¾ç½®ä¸ã§ãã対å¦æ¹æ³åãã£ãã追è¨ãã¾ãï¼
ã²ã¹ãããã¯ãããã¯ã§ã¯ã³ã¢ã«ããã®é¨åãåå ã ã£ãã¿ããã§ä»¥ä¸ã®ããã«ä¿®æ£ãããpjaxé·ç§»ãã¾ããã空ã®ã¢ã³ã«ã¼ãå½±é¿ãã¦ãã®ããããã¾ããã