Blogposts inkorten
Ik ben een voor mij nieuw CMS aan het testen (Pluck CMS). Dit CMS is heel gebruiksvriendelijk vind ik. Er zit een blogmodule in, die ik graag wil gebruiken. Alleen als er meerdere blogposts zijn aangemaakt dan worden deze allemaal onder elkaar weergegeven.
Ik zou graag willen dat alleen de laatste blogpost wordt weergegeven en dat de oudere blogposts worden weergegeven als een link naar de orginele blogpost. Als je begrijpt wat ik bedoel.
Nu heb ik de maker van het CMS gevraagd of hij me hierbij kan helpen. Maar hij heeft geen tijd om me te helpen. Dus toen dacht ik aan jullie.
Kan iemand van jullie mij een voorzet/aanwijzing geven hoe ik dit moet aanpakken?
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/*
* This file is part of pluck, the easy content management system
* Copyright (c) somp (www.somp.nl)
* http://www.pluck-cms.org
* Pluck is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* See docs/COPYING for the complete license.
*/
//Make sure the file isn't accessed directly
if((!ereg("index.php", $_SERVER['SCRIPT_FILENAME'])) && (!ereg("admin.php", $_SERVER['SCRIPT_FILENAME'])) && (!ereg("install.php", $_SERVER['SCRIPT_FILENAME'])) && (!ereg("login.php", $_SERVER['SCRIPT_FILENAME']))){
//Give out an "access denied" error
echo "access denied";
//Block all other code
exit();
}
//Check if we want to include blog
if ($incblog) {
foreach ($incblog as $blogcat => $value) {
//Check if the album exists
if (file_exists("data/blog/$blogcat")) {
//Readout the posts
$dir = "data/blog/$blogcat/posts";
$path = opendir($dir);
while (false !== ($file = readdir($path))) {
if(($file !== ".") and ($file !== "..")) {
if(is_file($dir."/".$file))
$files[]=$file;
else
$dirs[]=$file;
}
}
if($files) {
rsort($files);
foreach ($files as $file) {
//Include Translation data
include ("data/inc/lang/langpref.php");
include ("data/inc/lang/en.php");
include ("data/inc/lang/$langpref");
//Include the post
include("data/blog/$blogcat/posts/$file");
echo "<div class=\"blogpost\" style=\"margin-top: 20px\">
<span class=\"posttitle\" style=\"font-size: 18px;\">$title</span><br />
<span class=\"postinfo\" style=\"font-size: 10px;\">$lang_blog14 <span style=\"font-weight: bold;\">$blogcat</span> - $postdate</span><br /><br />
$content
<p><a href=\"?blogpost=$file&cat=$blogcat&pageback=$filetoread\">» $lang_blog15</a></p></div>";
}
}
closedir($path);
}
}
}
?>
/*
* This file is part of pluck, the easy content management system
* Copyright (c) somp (www.somp.nl)
* http://www.pluck-cms.org
* Pluck is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* See docs/COPYING for the complete license.
*/
//Make sure the file isn't accessed directly
if((!ereg("index.php", $_SERVER['SCRIPT_FILENAME'])) && (!ereg("admin.php", $_SERVER['SCRIPT_FILENAME'])) && (!ereg("install.php", $_SERVER['SCRIPT_FILENAME'])) && (!ereg("login.php", $_SERVER['SCRIPT_FILENAME']))){
//Give out an "access denied" error
echo "access denied";
//Block all other code
exit();
}
//Check if we want to include blog
if ($incblog) {
foreach ($incblog as $blogcat => $value) {
//Check if the album exists
if (file_exists("data/blog/$blogcat")) {
//Readout the posts
$dir = "data/blog/$blogcat/posts";
$path = opendir($dir);
while (false !== ($file = readdir($path))) {
if(($file !== ".") and ($file !== "..")) {
if(is_file($dir."/".$file))
$files[]=$file;
else
$dirs[]=$file;
}
}
if($files) {
rsort($files);
foreach ($files as $file) {
//Include Translation data
include ("data/inc/lang/langpref.php");
include ("data/inc/lang/en.php");
include ("data/inc/lang/$langpref");
//Include the post
include("data/blog/$blogcat/posts/$file");
echo "<div class=\"blogpost\" style=\"margin-top: 20px\">
<span class=\"posttitle\" style=\"font-size: 18px;\">$title</span><br />
<span class=\"postinfo\" style=\"font-size: 10px;\">$lang_blog14 <span style=\"font-weight: bold;\">$blogcat</span> - $postdate</span><br /><br />
$content
<p><a href=\"?blogpost=$file&cat=$blogcat&pageback=$filetoread\">» $lang_blog15</a></p></div>";
}
}
closedir($path);
}
}
}
?>
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
$string = "Een stukje teks met veel letters. Lorem ipsum dolor sit amet.";
if(strlen($string) > 10 && empty($_GET['readmore'])) {
for($i=10; true; $i++) {
if($string{$i} == '.' || $i > strlen($string)) {
print substr($string, 0, $i) . '... (<a href="?readmore=true">read more</a>)';
break;
}
}
} else {
print $string;
}
?>
$string = "Een stukje teks met veel letters. Lorem ipsum dolor sit amet.";
if(strlen($string) > 10 && empty($_GET['readmore'])) {
for($i=10; true; $i++) {
if($string{$i} == '.' || $i > strlen($string)) {
print substr($string, 0, $i) . '... (<a href="?readmore=true">read more</a>)';
break;
}
}
} else {
print $string;
}
?>