danreeves / picotags

[Deprecated] Adds page tagging functionality to Pico.
MIT License
4 stars 3 forks source link

Error 404 on tag pages and a PHP warning for line 65 #1

Closed bricebou closed 9 years ago

bricebou commented 9 years ago

Hi,

I've just installed picocms and your plugin picotags.

On my local installation, everythink works like a charm ; but on the server I'm using I have an error:

Warning: Invalid argument supplied for foreach() in /home/bricebou/www/plugins/picotags.php on line 65

You can verify it on http://momh.fr

Here is my index page:

<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
    <meta charset="utf-8" />

    <title>{% if meta.title %}{{ meta.title }} | {% endif %}{{ site_title }}</title>
{% if meta.description %}
    <meta name="description" content="{{ meta.description }}"> 
{% endif %}{% if meta.robots %}
    <meta name="robots" content="{{ meta.robots }}">
{% endif %}

    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400,700" type="text/css" />
    <link rel="stylesheet" href="{{ theme_url }}/style.css" type="text/css" />

    <script src="{{ theme_url }}/scripts/modernizr-2.6.1.min.js"></script>
    <link href="{{ theme_url }}/scripts/syntaxhighlighter/styles/shCore.css" rel="stylesheet" type="text/css" />
    <link href="{{ theme_url }}/scripts/syntaxhighlighter/styles/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <script src="{{ theme_url }}/scripts/syntaxhighlighter/scripts/shCore.js"></script>
    <script src="{{ theme_url }}/scripts/syntaxhighlighter/scripts/shAutoloader.js"></script>
</head>
<body>

    <header id="header">
        <div class="inner clearfix">
            <h1><a href="{{ base_url }}">{{ site_title }}</a></h1>

            {{ at_navigation.navigation }}
        </div>
    </header>

    <section id="content">
        <div class="inner">
            {% if is_front_page %}
            <!-- front page -->
                <!-- {% for page in pages %}

                        <article>
                            <h2><a href="{{ page.url }}">{{ page.title }}</a></h2>
                            <p class="meta">Tags:
                                {% for tag in page.tags %}
                                    <a href="{{ base_url }}/tag/{{ tag }}">#{{ tag }}</a>
                                {% endfor %}
                            </p>
                            {{ page.excerpt }}
                        </article>

                {% endfor %} -->
                {{ content }}
            <!-- front page -->
            {% elseif meta.tags %}
            <!-- blog post -->
                <article>
                    <!-- <h2>{{ meta.title }}</h2> -->
                    {{ content }}
                    <p class="meta">Tags :
                        {% for tag in meta.tags %}
                            <a href="{{ base_url }}/tag/{{ tag }}">#{{ tag }}</a>
                        {% endfor %}
                    </p>
                </article>
            <!-- blog post -->

            {% elseif pages and meta.title != 'Error 404' %}
            <!-- tags page -->
                <p>Posts tagged <a href="{{ page.url }}">#{{ current_tag }}</a>:</p>
                {% for page in pages %}

                        <article>
                            <h2><a href="{{ page.url }}">{{ page.title }}</a></h2>
                            <p class="meta">Posted on {{ page.date_formatted }} by {{ page.author }}
                                <span class="tags"><br />Tags :
                                    {% for tag in page.tags %}
                                            <a href="{{ base_url }}/tag/{{ tag }}">#{{ tag }}</a>
                                    {% endfor %}
                                </span>
                            </p>
                            {{ page.excerpt }}
                        </article>
                {% endfor %}
                All tags :
                    <ul class="tags">
                        {% for tag in tag_list %}
                        <li><a href="/tag/{{ tag }}">#{{ tag }}</a></li>
                        {% endfor %}
                    </ul>
            <!-- tags page -->
            {% else %}
            <!-- single page -->
            <article>
                <!-- <h2>{{ meta.title }}</h2> -->
                {{ content }}
            </article>
            <!-- single page -->
            {% endif %}
        </div> <!-- END .inner -->
    </section>
    <footer id="footer">
        <div class="inner">
            <a href="http://pico.dev7studios.com">Pico</a> was made by <a href="http://gilbert.pellegrom.me">Gilbert Pellegrom</a> 
            from <a href="http://dev7studios.com">Dev7studios</a>.
        </div>
    </footer>
    <script type="text/javascript">
        SyntaxHighlighter.autoloader(
            'js jscript javascript  {{ theme_url }}/scripts/syntaxhighlighter/scripts/shBrushJScript.js',
            'tex latex              {{ theme_url }}/scripts/syntaxhighlighter/scripts/shBrushLatex.js',
            'php                    {{ theme_url }}/scripts/syntaxhighlighter/scripts/shBrushPhp.js',
            'txt plain text         {{ theme_url }}/scripts/syntaxhighlighter/scripts/shBrushPlain.js',
            'bash shell             {{ theme_url }}/scripts/syntaxhighlighter/scripts/shBrushBash.js',
            'perl                   {{ theme_url }}/scripts/syntaxhighlighter/scripts/shBrushPerl.js',
            'xml xhtml xslt html    {{ theme_url }}/scripts/syntaxhighlighter/scripts/shBrushXml.js'

        );

        SyntaxHighlighter.all();
    </script>
</body>
</html>
danreeves commented 9 years ago

Hey bricebou,

I just updated it, can you check if it's fixed with the latest version?

bricebou commented 9 years ago

Hi,

With this version, I don't have PHP warnings anymore but I have a 404 error for each tag page :/

I really don't understand, on my local wamp, it's working.

How can I track the error (is it PHP, Apache...) ?

bricebou commented 9 years ago

Hi Dan,

After searching a little while, I've noticed the fork made by Philipp Schmitt : https://github.com/pschmitt/picotags.

I've tried his version and everything works great ! See http://momh.fr/tag/terminal for example.

I don't really know why, but I have pages with no tags, that his version seems to accept.

Thanks again :)

danreeves commented 9 years ago

Cool, glad you got it working. I did ask him for a pull request before but he never replied. I've now merged in his changes since you confirmed that it works.

Sorry I didn't have a chance to help you out, I currently have no internet at home.

bricebou commented 9 years ago

No problem, on the contrary thanks to you :)