ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Entries not showing for some users on some pages

July 19, 2011 9:09pm

Subscribe [4]
  • #1 / Jul 19, 2011 9:09pm

    GrowOrganic

    16 posts

    Hello,

    I am porting a site over from Wordpress to EE, and have gotten all the data squared away for the most part.

    When I browse the main blog page on my site I can see that the entries and the authors all match up, however, when I go to an author’s individual blog page, only a few authors actually generate a list of their blog entries.

    I am using the query module to find the author (based on segment_1) and then pass that to an embedded template (given the member id) which then shows either the profile or the blog depending on segment 2.

    The members for the site (all part of the same field group) are divided into three sections, the freshman (joined this year), the sophmores (joined last year), and the graduates (joined 2 years ago.

    However so far only the second group is showing their posts (the first group has no posts, so it is expected that they don’t have any).  The graduates do have posts, and they are visible on the main page (which shows everyone’s blog).

    If I view a test template outside of the segment_1 if statement, it does show all the graduate’s posts, so I am thinking it is something to do with the query.  I have tried to use php to store the value and pass it on, but that didn’t work.  Below are two snippets which I tried:

    {if segment_1}
    {exp:query to get member_id}<?php $var="{member_id}">{/exp:query}
    {embed="template_group/template" mem_id="<?php echo $var; ?>"}
    {if:else}
    home page
    {/if}
    {if segment_1}
    {exp:query sql="SELECT member_id FROM ee_members WHERE group_id = '6' AND username = '{segment_1}'"}
    {embed="template_group/template" mem_id="{member_id}"}
    some page  <-- putting the test template here does not work
    {/exp:query}
    {if:else}
    home page  <-- putting the test template here works
    {/if}

    Any ideas on what it could be?

    Oh, and another thing: all traffic goes to the index page, which embeds the profile page, which embeds the blog page, which embeds either the blog_list page or the blog_entry page (depending on pagination).  Not sure if this would have any affect on anything.

    Thanks,
    Jason

    EE v 2.2.0, using MSM
    Build:  20110622

  • #2 / Jul 20, 2011 5:20pm

    Brandon Jones

    5500 posts

    Hi groworganic,

    I’d suggest updating to 2.2.1, as it does solve a number of issues with 2.2.0. This probably isn’t one of them, though. If you try your queries by themselves in a non-embedded, otherwise empty test template, does it work? It sounds like some reduction testing would be helpful here.

  • #3 / Jul 20, 2011 5:31pm

    GrowOrganic

    16 posts

    Hi Brandon,

    I actually was in the middle of typing up a reply here 😊

    It works right now if I use a static number (like “85”) rather than an embedded variable, though the embedded variable does output the right number when I call it in that same template.  What is strange is that it works for some embedded variables and not for others… maybe there are some ‘extra bits’ being added on to some of the embedded variables?

    Going to keep plucking away at this…

    Thanks,
    Jason

  • #4 / Jul 20, 2011 6:01pm

    GrowOrganic

    16 posts

    so now with my test template, I have it so that it no longer shows the no_results for my exp:channel:entries, but it also doesn’t display the results either… strange

    This is my exact template

    hello!
    {exp:query sql="SELECT member_id FROM ee_members WHERE group_id = '6' AND username = '{segment_2}'"}
        {exp:channel:entries channel="blog-post" orderby="date" limit="10" author_id="{member_id}"}
            {title}
            {if no_results}404{/if}
        {/exp:channel:entries}
    {/exp:query}

    it still returns results if I input the sophomore members, but nothing (not even the no_results) for the graduates except the “hello!” at the beginning.

    Then if I have another test template with just the exp:channel:entries and a specific author_id it works.  (note that if I put the specific author_id in the above, and it is one of the graduates, it will also not show)

    My next idea would be that maybe the earliest post is before the join date, though I don’t think this is the case, going to update the join dates just in case and see if it fixes it.

    Thanks,
    Jason

  • #5 / Jul 22, 2011 10:40am

    Kyle Cotter

    730 posts

    Hey Jason,

    In your original post you made a conditional with “segment_1”, but you never passed it a value.

    It should look something like:

    {if segment_1 == "value"}
    ...
    {/if}

    Here are the docs on Conditional Global Variables.

    Once that conditional is working right, hopefully everything else will work!

    Thanks! 😊

  • #6 / Jul 22, 2011 1:32pm

    GrowOrganic

    16 posts

    Hi Kyle,

    I changed it to

    {if segment_1 != ""}

    but still it doesn’t work.

    I am pretty sure it is something to do with the queries (using both the exp:channel:entries, and the exp:query), as I simplified it to just those two (see post 3) and it doesn’t work as expected with all the members.

    The other thing of note is that I added the sophomore members first and the graduates and freshman afterwards, and then went and changed join_date in the database.

    The users 81-86 (the graduates) are not showing their individual blogs (though their posts show on the main page), however 77-80 and 87-89 are showing their individual blog posts.  I tried changing the join_date of one of the 81-86 users to a later date (of one that works), however that did not let them show up.

    Thanks again for your help and suggestions,
    Jason

  • #7 / Jul 25, 2011 2:05pm

    GrowOrganic

    16 posts

    Hello,

    So I can solve this by making new members, but when I move the old user’s username over it messes up, also I can change the username and it starts working fine again.

    Say, for example, one of my graduates is “imagraduate”, as “imagraduate” his posts will not show, but if I change his username to “imagraduate2” suddenly his posts appear!

    I then changed it so that the username is more hidden and that it uses a custom field to determine if the segment_1 is a user or an entry, but it still runs into the same problem with the graduates.

    Thanks again,
    Jason

  • #8 / Jul 26, 2011 4:58pm

    Brandon Jones

    5500 posts

    Hi Jason,

    So just to clarify here, all new members created through the control panel work fine? If that’s the case, that would point to a problem with the original data import. I usually recommend DataGrab in these cases.

  • #9 / Jul 26, 2011 8:50pm

    GrowOrganic

    16 posts

    Hello Brandon,

    They work until I change the username to one of the ones that used to be one of the graduates. And then they stop working.

    What tables should I be changing when I import? I changed the channel_titles, channel_data, and comments.  I already had the members set up from before. Anything else?

    I will ask about the possibility of using DataGrab, though I am on a pretty strict budget, so I am not sure if that is an option or not.

    Thanks,
    Jason

  • #10 / Jul 28, 2011 4:36pm

    Sue Crocker

    26054 posts

    Hi, groworganic.

    You’re going to need to audit the number of rows you have for the following three tables:

    exp_members
    exp_member_data
    exp_member_homepage

    Are there the same number of rows for each of these tables?

  • #11 / Jul 28, 2011 5:23pm

    GrowOrganic

    16 posts

    Hello Sue,

    Yes they all have the same amount of rows.

    Thanks,
    Jason

  • #12 / Aug 01, 2011 2:49pm

    Brandon Jones

    5500 posts

    Hi Jason,

    When you say changing their username works, what exactly are you changing in the database, and what SQL are you using to test? Be sure to get your test as reduced as possible.

    Also, were you ever able to upgrade to the latest version?

  • #13 / Aug 01, 2011 4:05pm

    GrowOrganic

    16 posts

    Hi Brandon,

    Ok, reduced to simplest terms:

    If I use the segment_1 in a exp:query to get the member_id it will return the correct id if it exists.
    Then if I pass that id to the exp:channel as the author, it returns nothing (not even the no_results) for some segment_1s, even if they had a bunch of posts.

    I was using the username at first to generate the segment_1s (using links), but I changed this for some added security. Instead I now use a custom field to determine the segment_1 and updated the query accordingly.  If I change the segment_1 (via the custom field) to something other than one of the “bad” segment_1s, all their posts are visible, but if it is one of the previous “bad” segment_1s their posts are gone.

    Could it be something to do with strict URLs being disabled? Due to the structure of the site, having this off makes it easier to maintain.

    This is my current code, for the simplest version see this post.

    {exp:query sql="SELECT ee_members.member_id FROM ee_members, ee_member_data WHERE ee_members.group_id = '6' AND ee_member_data.m_field_id_6 = '{segment_1}' AND ee_members.member_id = ee_member_data.member_id"}
        {embed="freshman-farmer/FF_profile" farm="{member_id}"}
    
        {if no_results}
            {if segment_1 == "about-the-program"}{embed="freshman-farmer/FF_about"}
            {if:elseif segment_1 == "archive"}{embed="freshman-farmer/FF_list" year="{segment_2}" month="{segment_3}"}
            {if:elseif segment_1 == "category"}{embed="freshman-farmer/FF_category"}
            {if:elseif segment_1 == "post"}{embed="freshman-farmer/FF_post"}
            {if:elseif segment_1 == "press"}{embed="freshman-farmer/FF_press"}
            {if:elseif segment_1 == "preview"}{embed="freshman-farmer/FF_preview"}
            {if:elseif segment_1 == "tag"}{embed="freshman-farmer/FF_tag"}
            {if:elseif segment_1 == "the-farms"}{embed="freshman-farmer/FF_farms"}
            {if:else}{embed="freshman-farmer/FF_blog" seg="1"}{/if}
        {/if}
    {/exp:query}

    So right now I have a simple workaround in place (by appending a word to the custom field), but I would like to fix this and be able to use those segment_1s correctly.

    I have not yet found the time to upgrade to 2.2.1 yet, and the upgrade from 2.1.3 to 2.2.0 was a bear (had database table issues and file corruption) which makes me hesitant to do it, but hopefully this one will be easier. But now my other projects are finished, and I just need to get permission to take the system down for a while.  So I will post here when I do get it upgraded.

    Thanks,
    Jason

  • #14 / Aug 01, 2011 6:22pm

    Brandon Jones

    5500 posts

    Thanks for the clarification. Just for “fun”  😉 can you also try adding dynamic=“no” to your exp:channel:entries tag?

  • #15 / Aug 01, 2011 6:49pm

    GrowOrganic

    16 posts

    Thanks, dynamic=“no” looks like it did the trick.

    Any reason why it worked for some and not for others?

    Jason

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases