Skip to content

Files

Latest commit

370e888 · Jan 19, 2025

History

History

serendipity_event_freetag

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Apr 23, 2016
Dec 13, 2011
Sep 28, 2014
Jan 19, 2025
Oct 2, 2014
Oct 2, 2014
Sep 28, 2014
Sep 28, 2014
Sep 28, 2014
Oct 2, 2014
Oct 2, 2014
Mar 14, 2014
Mar 14, 2014
Aug 12, 2013
Dec 28, 2013
Dec 28, 2013
Sep 28, 2014
Sep 28, 2014
Aug 12, 2013
Aug 12, 2013
Aug 12, 2013
Aug 12, 2013
Apr 23, 2016
Aug 12, 2013
Aug 12, 2013
Jun 2, 2014
Dec 13, 2011
Jan 19, 2025
Jul 12, 2021
Dec 13, 2011
Dec 13, 2011
When using extended smarty output, the following code illustrates how the
smarty-variables could be used when dropped into the entries.tpl:

{if isset($entry.freetag.extended) && $entry.freetag.extended == 1}
	{if $entry.freetag.tags.tags}
		<div class="serendipity_freeTag">{$entry.freetag.tags.description}
			{foreach from=$entry.freetag.tags.tags item="tag"}
				{$tag}
			{/foreach}
		</div>

		{if $is_single_entry or $is_preview}
			{$entry.freetag.related.description}
			<ul class="serendipity_freeTag_related">
			{foreach from=$entry.freetag.related.entries item="link"}
				<li>{$link}</li>
			{/foreach}
			</ul>
		{/if}
	{/if}
{else}
	{$entry.freetag}
{/if}




Using this subquery you can convert existing categories to tags:

INSERT INTO serendipity_entrytags (entryid, tag)
  SELECT serendipity_entries.id, serendipity_category.category_name
    FROM serendipity_entries, serendipity_category, serendipity_entrycat
   WHERE serendipity_entrycat.entryid = serendipity_entries.id
     AND serendipity_category.categoryid = serendipity_entrycat.categoryid;

[quoted from: http://pixelated-dreams.com/archives/229-Spring-Cleaning.html]

Or using this script you can convert existing categories to tags:

<?php
include 'serendipity_config.inc.php';

$rows = serendipity_db_query("SELECT e.id, e.title, c.category_name
                                FROM {$serendipity['dbPrefix']}entries AS e
                                JOIN {$serendipity['dbPrefix']}entrycat AS ec
                                  ON ec.entryid = e.id
                                JOIN {$serendipity['dbPrefix']}category AS c
                                  ON ec.categoryid = c.categoryid");

foreach($rows AS $row) {
    serendipity_db_query(
        sprintf(
            "REPLACE INTO {$serendipity['dbPrefix']}entrytags (entryid, tag) VALUES (%d, %s)",
            (int)$row['id'],
            serendipity_db_escape_string($row['category_name'])
        )
    );

    printf(
        "Category '%s' added as Tag for Entry #%d, '%s'<br />\n",
        htmlspecialchars($row['category_name']),
        (int)$row['id'],
        htmlspecialchars($row['title'])
    );
}



The following code illustrates on how to change your templates entries.tpl file in case of enabled option 'tags-as-list':

{serendipity_hookPlugin hook="entries_header" addData="$entry_id"}

{if $taglist}
    <article id="taglistentries" class="clearfix serendipity_entry">
        <div class="clearfix content serendipity_entry_body">
            <h2>{$head_subtitle}</h2>
    {foreach from=$entries item="dategroup"}
        {foreach from=$dategroup.entries item="entry"}

            <div class="static-entries-list">
                ({$dategroup.date|date_format:"%d.%m.%Y"}) <a href="{$entry.link}">{$entry.title|default:$entry.id}</a>
            </div>

        {/foreach}
    {/foreach}

        </div>
    </article>

{else}

--- OLD CODE START-and keep --

{foreach from=$entries item="dategroup"}
    {foreach from=$dategroup.entries item="entry"}
    {assign var="entry" value=$entry scope="parent"}
    *** LONG CODE FOR THE entries output article ***
    {/foreach}
{foreachelse}
    {if not $plugin_clean_page}
    <p class="nocontent">{$CONST.NO_ENTRIES_TO_PRINT}</p>
    {/if}
{/foreach}

--- OLD CODE END and keep---

{/if}{* not taglist end *}

--- OLD CODE FOOTER INFO START and keep ---

{if $footer_info or $footer_prev_page or $footer_next_page}
    *** inside CODE ***
{/if}

--- OLD CODE FOOTER INFO END and keep ---

    {serendipity_hookPlugin hook="entries_footer"}