PDA

View Full Version : Hoping someone with a PHP and CMPS clue can tell me what's wrong here.


Bryant
06-13-2004, 07:13 PM
I desperately need a CMPS module for v3articles (http://www.vbulletin.org/forum/showthread.php?t=65934&highlight=article), and after asking about it in a couple places a few days ago, decided I'd try to see if I could make one myself.

First, let me say I know no PHP, I have no real capacity with code, I've just been slogging through this with trial and error for the past few days. So if something is stupidly handled below, that's why. ;)

When I use eval('print_output, and run this .php file from the modules directory for CMPS, it successfully pulls the featured article and displays it. But when I comment out print_output, and replace it with eval('$home[$mods as other modules use, it doesn't pull anything at all into the module I created on the site. For the sake of simplicity, I'm not even trying to pull the featured article image, if there is one. One thing at a time.

Is there an easy answer as to why it won't populate the module on the CMPS index page?

<?php

// Enter the full path to your forum here.
chdir('/path_here');

// get special data templates from the datastore
$specialtemplates = array(
'attachmentcache',
'featuredarticle'
);

// pre-cache templates used by all actions
// $globaltemplates = array(
// 'adv_portal_ARTICLE'
// );

// pre-cache templates used by specific actions
$actiontemplates = array(
'article_cmps'
);

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once('./includes/functions_articles.php');

// ###################### FEATURED ARTICLE TEASER ########################
$featuredarticle = unserialize($datastore['featuredarticle']);
if ($featuredarticle['id'])
{
$feature = $DB_site->query_first("SELECT article.*, articlepost.*, articlecategory.options AS options FROM " . TABLE_PREFIX . "article AS article
INNER JOIN " . TABLE_PREFIX . "articlepost AS articlepost ON (articlepost.postid = article.firstpostid)
INNER JOIN " . TABLE_PREFIX . "articlecategory AS articlecategory ON (articlecategory.categoryid = article.categoryid)
WHERE article.articleid=$featuredarticle[id]");
}
if (!empty($feature['title']))
{

// do html
if ($feature['options'] & 256)
{
$dohtml = 1;
}

if ($feature['options'] & 512)
{
$dosmilies = 1;
}

// get an attachment, if there's one with a thumnail
// $attachment = $DB_site->query_first("SELECT attachmentid FROM " . TABLE_PREFIX . "articleattachment WHERE articleid=$featuredarticle[id] AND thumbnail_dateline>1 ORDER BY RAND() LIMIT 0,1");
// if (!empty($attachment['attachmentid']))
// {
// $GLOBALS['isattachment'] = true;
// }

require_once('./includes/functions_bbcodeparse.php');
$feature['postbody'] = truncate_text($feature['postbody'], $vboptions['featuredlength'], 1);
$feature['postbody'] = parse_bbcode2($feature['postbody'], $dohtml, 0, $dosmilies, 1);

eval('$articlecontent .= "' . fetch_template('article_cmps') . '";');
}
// eval('print_output("' . fetch_template('adv_portal_blog') . '");');
eval('$home[$mods[\'modid\']][\'content\'] .= "' . fetch_template('adv_portal_blog') . '";');
?>

Thanks in advance for any insight.

Bryant
06-13-2004, 11:09 PM
There's someone else's thread on a similar issue here (http://www.vbadvanced.com/forum/showthread.php?t=1300), just as an FYI. Still hoping someone can shed some light here, but I'll just be happy when any v3articles->CMPS module is ready.

Our Sponsors
 

Brian
06-15-2004, 11:42 AM
Well I can tell you that first off, all of this should be removed:

// Enter the full path to your forum here.
chdir('/path_here');

// get special data templates from the datastore
$specialtemplates = array(
'attachmentcache',
'featuredarticle'
);

// pre-cache templates used by all actions
// $globaltemplates = array(
// 'adv_portal_ARTICLE'
// );

// pre-cache templates used by specific actions
$actiontemplates = array(
'article_cmps'
);

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');


Other than that, I don't see anything obviously wrong. Can you show me the templates and the info you used when adding the module?

+decipher
06-15-2004, 02:27 PM
There's someone else's thread on a similar issue here (http://www.vbadvanced.com/forum/showthread.php?t=1300), just as an FYI. Still hoping someone can shed some light here, but I'll just be happy when any v3articles->CMPS module is ready.

Since there are a few people working on this I will post what I have accomplished so far. I have approached this in a more "permanent" way, it adds tables to the vbAdvanced settings and everything.

Installer:

Installs settings, phrases, templates and everything. I did it this way so I can turn various options on and off as I see fit.

Options:
Look at the news options in VBA CMPS and I just replicated that. I added a category icon thing and a category title thing as well. I was having some mySQL errors, but once I fixed those it still displayed nothing.

Like I said in my other post, 90% of the code (the installer, and the article.php file) is from the vba cmps files themselves. If Bryan will let me, I will zip everything up with some quick documentation and attach it so someone else can finish it up and get it working.

I really have no idea what I am doing here really, so if I am allowed to post what I have done it would be great.

Our Sponsors
 

Bryant
06-15-2004, 07:15 PM
Since there are a few people working on this I will post what I have accomplished so far. I have approached this in a more "permanent" way, it adds tables to the vbAdvanced settings and everything.

Installer:

Installs settings, phrases, templates and everything. I did it this way so I can turn various options on and off as I see fit.

Options:
Look at the news options in VBA CMPS and I just replicated that. I added a category icon thing and a category title thing as well. I was having some mySQL errors, but once I fixed those it still displayed nothing.

Like I said in my other post, 90% of the code (the installer, and the article.php file) is from the vba cmps files themselves. If Bryan will let me, I will zip everything up with some quick documentation and attach it so someone else can finish it up and get it working.

I really have no idea what I am doing here really, so if I am allowed to post what I have done it would be great.


decipher, I think we're both falling prey to the same problem. Like I said, I was able to get it to spit out the featured article on its own page by running the .php from the /modules directory, but for some reason, it will not work once pulled into the CMPS index.

Brian, appreciate you taking a look, here are the two templates;

adv_portal_blog;
<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder" width="100%">
<tr>
<td class="tcat">Featured Blog</td>
</tr>
<tr>
<td class="$getbgrow" align="left" valign="top" width="100%">$articlecontent</td>
</tr>
</table>
<br />

article_cmps;
<span class="smallfont">$feature[postbody] <a href="article.php?a=$featuredarticle[id]">continued</a></span>


The settings I used to create the module were pretty cut and dry. Pointed to the .php file, set it to active, and put "adv_portal_blog,article_cmps" in Templates Used.

Brian
06-15-2004, 07:52 PM
I think I may see the problem. You're using the variable $datastore['featuredarticle'] in the code, which indicates that you're trying to pull some cached data from the datastore table. Did you add the 'featuredarticle' field to your specialtemplates array? If not, open your global.php file and look for:


'adv_modules',
'adv_portal_opts',


Replace that with:


'adv_modules',
'adv_portal_opts',
'featuredarticle',



Let me know if that helps. :)

Shack Networks
06-15-2004, 08:07 PM
That worked fine m8 :) is there any way of pulling more than one article ?

H

+decipher
06-15-2004, 08:17 PM
Think you can take a look at what I am attempting to do as well? Everything that I put in the datastore table is already using the "adv_portal_ops" so I would assume that I wouldn't need to add any other specialtemplates correct?

I fear putting the files up here because the code isn't really mine. I am sure that there might be an easier way to do it, but I like having options. I have no idea what the hell I am doing but I am trying.

Let me know please. I'd imagine that most of the work is already done, I just need to figure out the query to pull all the info correctly and then get it to display.

I guess I will go over some of the info for what I have going on:
New rows in adv_settings



Var Group Value Defaultvalue Optioncode Displayorder
portal_article_enablearchive adv_portal_article 2 2 18
portal_article_archivepreview adv_portal_article 1 1 yesno 19
portal_article_maxarticle adv_portal_article 0 2 2
portal_article_maxchars adv_portal_article 500 500 3
portal_article_catid adv_portal_article 2 0 1
portal_article_allowcomments adv_portal_article 1 1 yesno 4
portal_article_showavatar adv_portal_article 1 1 yesno 6
portal_article_articleicon adv_portal_article 1 1 yesno 7
portal_article_showrating adv_portal_article 1 1 yesno 8
portal_article_showattachments adv_portal_article 1 1 yesno 5
portal_article_showsendfriend adv_portal_article 1 1 yesno 9
portal_article_enablehtml adv_portal_article 1 0 yesno 10
portal_article_enablevbcode adv_portal_article 1 1 yesno 11
portal_article_enablevbimage adv_portal_article 1 1 yesno 12
portal_article_enablesmilies adv_portal_article 1 1 yesno 13
portal_article_dateformat adv_portal_article M d, Y - g:i A M d, Y - g:i A 14
portal_article_categorytitle adv_portal_article 0 0 yesno 15
portal_article_categoryicon adv_portal_article 0 0 yesno 16

New row in adv_settinggroup
adv_portal_article

2 Rows in adv_modules
Article & Articlearchive (same settings as your news and news archive)

The options sits right underneath the news options in the default settings page for cmps, all the phrases/settings/templates were entered using the vba cmps installer.

If you are too busy to help thats cool with me, I would only need the OK to let someone else help me.

+decipher
06-15-2004, 08:22 PM
That worked fine m8 :) is there any way of pulling more than one article ?

H

If I can get mine working (and the ok to release it or whatever) it will pull as many articles as you want from as many categories as you want. It will look the same as the news does on an unhacked vba cmps however. I have no knowledge of getting it to look like vbportals does, I tried to do that with the news/forums and it didn't work how I though it would.

I did add the forum icon hack from Livewire to v3articles so it will be able to have category icons/images that are seperate from the users avatar. Handy if you have different categories and are looking for that "nuke" type look I guess.

Shack Networks
06-15-2004, 08:26 PM
OK I got it to display and did some template tweeking.

I want to know if theres any way this can be altered to say pull the top 5 latest articles from the database and display them as in the pic I posted.

H

Shack Networks
06-15-2004, 08:34 PM
Maybe also display the first attached image as a thumbnail next to the title and content ?

H

+decipher
06-15-2004, 08:39 PM
Maybe also display the first attached image as a thumbnail next to the title and content ?

H

You could adapt Livewires forumhomeicon hack. Add it to articlecategory, then pull it with your query couldn't you? It wouldn't be very dynamic but you wouldn't have to attach a new pic for every article either.

If I am way off here, I apologize, I have no idea what I am doing.

Bryant
06-15-2004, 11:46 PM
Let me know if that helps. :)

You're the greatest. It's working fine now. Exactly what I wanted. Thanks so much!

Brian
06-16-2004, 11:22 AM
You should post this in the Add-On Modules forum. ;)

+decipher
06-16-2004, 12:19 PM
Good job Bryant. Glad you made it work for yourself. I am completely stuck on mine. If I put the mySQl query in vba_cmps_include_top.php I don't recieve any errors any more. So at least I got that fixed (I guess). Everything is there, just nothing is being displayed.

I have been messing with this for about 4 days now. Think it's time to give up.

Bryant
06-16-2004, 08:04 PM
It's in the User Add-on Modules forum now, here (http://www.vbadvanced.com/forum/showthread.php?t=1357), thanks Brian.

It's also at vb.org here (http://www.vbulletin.org/forum/showthread.php?t=66237).

Decipher, I know a lot of people would probably be more interested in your implementation. Hopefully you can get it figured out.

If anyone downloaded the .zip I had in this thread, you may need to adjust the template I had in there depending on where you load your CMPS index from. It was missing '$vboptions[bburl]/' before, the current .zip has that, but wanted to point it out. Shouldn't affect most, but in my case, I load my front page from a different subdomain, so I needed that correction.