Elgg
Version 6.1
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
views
default
output
excerpt.php
Go to the documentation of this file.
1
<?php
10
$text
=
elgg_extract
(
'text'
,
$vars
,
''
);
11
$text
=
trim
(
elgg_strip_tags
(
$text
));
12
13
$suffix
=
elgg_extract
(
'suffix'
,
$vars
,
'...'
);
14
15
$string_length
=
elgg_strlen
(
$text
);
16
$num_chars
= (int)
elgg_extract
(
'num_chars'
,
$vars
, 250);
17
18
if
(
$string_length
<=
$num_chars
) {
19
echo
$text
;
20
return
;
21
}
22
23
// handle cases
24
$excerpt
=
elgg_substr
(
$text
, 0,
$num_chars
);
25
$space
=
elgg_strrpos
(
$excerpt
,
' '
, 0);
26
27
// don't crop if can't find a space.
28
if
(
$space
===
false
) {
29
$space
=
$num_chars
;
30
}
31
32
$excerpt
=
trim
(
elgg_substr
(
$excerpt
, 0,
$space
));
33
34
if
(
$string_length
!=
elgg_strlen
(
$excerpt
)) {
35
$excerpt
.=
$suffix
;
36
}
37
38
echo
$excerpt
;
$space
$space
Definition:
excerpt.php:25
$num_chars
$num_chars
Definition:
excerpt.php:16
trim
elgg_strlen
elgg_strlen()
Wrapper function for mb_strlen().
Definition:
mb_wrapper.php:53
elgg_strrpos
elgg_strrpos()
Wrapper function for mb_strrpos().
Definition:
mb_wrapper.php:89
elgg_extract
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition:
elgglib.php:256
$suffix
$suffix
Definition:
excerpt.php:13
$string_length
$string_length
Definition:
excerpt.php:15
elgg_substr
elgg_substr()
Wrapper function for mb_substr().
Definition:
mb_wrapper.php:195
$vars
$vars
Definition:
theme.php:5
$text
$text
Output view for elgg_get_excerpt.
Definition:
excerpt.php:10
elgg_strip_tags
elgg_strip_tags(string $string, string $allowable_tags=null)
Strip tags and offer plugins the chance.
Definition:
output.php:323
$excerpt
if($string_length<=$num_chars) $excerpt
Definition:
excerpt.php:24
Generated on Wed Dec 4 2024 00:00:23 for Elgg by
1.8.11