Search Results for 'code'
-
AuthorSearch Results
-
November 27, 2012 at 2:21 am #120808
Stephen Edgar
KeymasterHave a read of these three pages from the docs:
https://codex.bbpress.org/getting-started-with-bbpress/
https://codex.bbpress.org/shortcodes/
https://codex.bbpress.org/widgets/November 26, 2012 at 10:33 pm #120800Shane Gowland
ParticipantYou can use the shortcode in the PHP template files with the do_shortcode() function.
echo do_shortcode('[bbp-topic-index]');would do the trick.Of course; there is a performance overhead involved with making WordPress parse the shortcode before displaying the content. Using WP_Query and creating a custom loop would be the ideal method, but it’s also much trickier.
November 26, 2012 at 6:34 pm #120794In reply to: Is this what my first page is supposed to look like?
Halo Diehard
ParticipantWell, I’ve created a page and am using the shortcode and it seems to bypass the issue. For anybody having this layout trouble, the shortcodes can be found here:
November 26, 2012 at 3:07 pm #120790In reply to: How is the forum archive page generated?
Michael
ParticipantHi John James — thanks for responding, much appreciated.
Regarding get_the_ID() not working on an archive page, I understanding your point — there isn’t a page associated with it.
The only issue I have is that the Forum Archive page is associated (“partnered” to use the documentation phrase) with a real page, and essentially it is just a regular page with embedded shortcodes.
In my case, the partnered page has content and embedded shortcodes, and it has a real page ID (#1296 in my case). That’s what I wanted to find so I can extract information specific to that partnered page.
What am I doing with all this? Well, the short story is that certain specific pages on my website have some special header images attached above the_content(), and I have created a custom Template in my child theme to handle it. Information about the slug is extracted, which is used to lookup random images in a database of images.
I’m trying to keep a consistent approach with all pages, hence the use of a custom Template that I set as a page attribute in the editor.
None of this is fatal for my needs, but if a page is partnered with the Forum or Topic Archive pages, it seems like the selected Template for displaying those pages should come from the Template page attribute associated with it. Hence the need for post ID of the partnered page.
Cheers.
Michael
November 26, 2012 at 11:41 am #120781In reply to: Fix for users of s2member and bbPress 2.2
plannerguy
Participant@JJJ – need help in the same regard.
I’m using amember and not s2member – and I need to block users from bbpress when their subscription becomes inactive (which means they are assigned a WP role of “amember expired” by amember).
Will JJJ’s code or tzelding88’s code above achieve this? Will it sustain mapping so that when a user’s WP role changes, bbpress’s role changes as well?
Many thanks.
November 26, 2012 at 9:32 am #120777In reply to: bbPress 2.2.1 and 2.2.2 – list style missing
padekan
ParticipantOk , so it’s a bit of physician heal thyself but here’s how I fixed in case other people are having the problem.
I found this:
https://codex.bbpress.org/theme-compatibility/
which shows how to create a custom bbpress.css in 2.0 and later. Then I changed line 62 to be:
list-style-type: inherit /* was ‘none’ */;
(basically took out the none override for basic list elements).
Seems like overkill to have a complete copy of bbpress.css just to change one line but I could not find another place to override it. Tried playing around with trying a skeleton bbpress.css that @import’ed the default one but didn’t have much success with that.
Anyways, issue has been resolved, thanks!
regards, Paul
November 26, 2012 at 9:15 am #120775In reply to: use old theme with 2.2?
Shane Gowland
ParticipantbbPress is now a plugin for WordPress. That means that it doesn’t run without an install of WordPress.
As for the design; that’s entirely up to you. You can go with the default bbPress styles, use a WordPress theme that overrides them or apply your own CSS and make the forums totally original. I recommend having a good read of the bbPress 2.0+ documentation.
November 26, 2012 at 3:33 am #120771In reply to: How to use BBpress functions in WordPress?
John James Jacoby
Keymaster- Use a regular old WP_Query()
- Use a widget
- Use bbp_has_forums()
- Use the shortcode mentioned above
There are lots of examples, in the forums, on the codex, and in the bbPress code itself. Also, unclear what you mean by “latest forum.” Do you mean topics, or replies, or something else?
November 26, 2012 at 3:26 am #120770In reply to: How is the forum archive page generated?
John James Jacoby
KeymasterModifying core files is never the way. There are plenty of filters in place to override any bit of functionality regarding bbPress’s theme compat,
There are, as you’ve already found, numerous vectors depending on exactly what you want to accomplish. Each filter has an intended purpose, and solves a specific problem. The underlying code is identical to WordPress’s own template loader, until a template isn’t found (which is a majority of installations.) In that case, bbPress replaces the_content with template parts using page.php, or whatever is a match in the stack you found already.
Also, don’t forget about the typical WordPress templates: archive-forum.php, and archive-topic.php, etc…
To answer your question about why get_the_ID() doesn’t work on archive pages, why would it? It’s an archive, not a post/page. There is not ID to get.
From your posts here, you’ve basically solved much of what’s already in the codex regarding how some of these things work; also, I’m fuzzy on what problem you’re trying to solve. What is the end goal you’re working towards? I can give you some advice on what I think will work best.
November 26, 2012 at 1:04 am #120766In reply to: How is the forum archive page generated?
Michael
ParticipantOkay, I’ve made some further progress with method #3 above (hooking into bbp_get_bbpress_template ). Here’s the general approach I’m taking:
add_filter( 'bbp_get_bbpress_template', 'my_add_page_template', $templates );
function my_add_page_template( array $templates ) {
$page_template = get_post_meta( $post_id, '_wp_page_template', true );
if ( $page_template != 'default' )
array_unshift( $templates, $page_template );
return $templates;
}
The only issue I have right now is that $post_id is difficult to extract if the archive pages (Archive Base and Topics Base) are being displayed. Right now I am hard wiring it to the post_id of the Archive Base page (getting it from the editor), and it works okay but not what I want.
Since these pages (archives) are custom post types, I haven’t found an easy way to find their post_id’s, and querying globals like $post->ID and calling functions like get_the_ID() and url_to_postid() don’t work for custom post IDs ($post->ID and get_the_ID() return 0).
QUESTION: For a bbPress page that is currently being built for display, is the post_id of the page being stored somewhere in a bbPress global?
Michael
November 25, 2012 at 11:30 pm #120765In reply to: How to use BBpress functions in WordPress?
Stephen Edgar
KeymasterUse the [bbp-forum-index] shortcode https://codex.bbpress.org/shortcodes/
November 25, 2012 at 7:24 pm #120752Stephen Edgar
KeymasterBasically all these functions names need to be unique…
If you use the above from @JJJ with ‘foo’ and then you use another function from another topic called ‘bar’ and then use a third again called ‘foo’ you will now have a conflict because two custom functions are trying to use ‘foo’.
A common practice is to name the functions with something to remind yourself (or others reading your code) that it is custom code you have added to your install.
eg. Prefixing ‘foo’ with ‘hd_’ for ‘Halo Diehard’
function hd_foo( $args = array() ) { $args['teeny'] = false; return $args; } add_filter( 'bbp_after_get_the_content_parse_args', 'hd_foo' );Better yet, a more descriptive name again with ‘hd_’ Halo Diehard prefix.
function hd_custom_teeny_mce_override( $args = array() ) { $args['teeny'] = false; return $args; } add_filter( 'bbp_after_get_the_content_parse_args', 'hd_custom_teeny_mce_override' );November 25, 2012 at 7:01 pm #120751In reply to: Migrate under my xoops forum to bbPress
Stephen Edgar
KeymasterHere are the steps I would follow:
– Backup everything and often (WordPress, Xooops, MySQL etc)
– Install WordPress locally to test the import
– Research the Xoops MySQL database structure
– Make a copy of importer example.php as xoops.php in the same folder
– Edit xoops.php to match the xoops database table & field nameseg. This from Example.php:
// Forum id. Stored in postmeta.
$this->field_map[] = array(
'from_tablename' => 'forum',
'from_fieldname' => 'forumid',
'to_type' => 'forum',
'to_fieldname' => '_bbp_forum_id'
);Would become:
// Forum id. Stored in postmeta.
$this->field_map[] = array(
'from_tablename' => 'xoops_forum_table_name',
'from_fieldname' => 'xoops_forumid',
'to_type' => 'forum',
'to_fieldname' => '_bbp_forum_id'
);The above is not accurate as I have no idea what table and field names xoops uses for its database, that is the bits you need to research. Do the above for as much as you can matching all the tables and fields testing your import.
Once you have an import working and are happy with you can then look to importing it to your live site and I cannot emphasize this enough, backuyp, backup and more backups in case things go wrong.
November 25, 2012 at 4:31 pm #120748Halo Diehard
ParticipantThank you for your quick response, I guess what I’m trying to convey is my uncertainty whether or not I can just plug that code in and rename “foo” anything? I don’t understand why I have to rename the foo, so I thought perhaps there was another step as well it was assumed I would know. (aka: you also have to put “” into your html)
Sorry I’m such a “foo” when it comes to coding 😉 I’m learning as fast as I can!
Wait, I might understand! We rename “foo” so we can recognize what it does when we’re looking at the code?
November 25, 2012 at 12:41 pm #120740Hansaplastique
ParticipantFor some reason my code didn’t stick; I mean remove:
bb_new_topic_link();November 25, 2012 at 12:34 pm #120739Hansaplastique
Participant+1 for me.
I installed “bbPress Topics for Posts” (plugin link).
I wanted to create one forum that collects comments on articles (this plugin does that very well – only downside is that comments made in the forum do not count as comments but are visible).Anyhow; I want users to be able to reply, but NOT create new topics.
Right now it’s either no new topics and no new replies, OR new topics and new replies.Of course I could modify the forum.php and remove the
for the specific forum. Is there an easier (more future proof) way?November 25, 2012 at 11:10 am #120738In reply to: How is the forum archive page generated?
Michael
ParticipantOkay, after some sleuthing I’ve figured out why page.php is *always* called to display the Archive Base and Topic Base.
The set of available templates appears to be hard-wired in (rather than selecting from all available Templates in the selected Theme) in bbp_get_theme_compat_templates() in …/bbpress/includes/core/template-loader.php.
bbPress appears to want to select from a known list of “bbPress friendly” Templates to display pages, so it uses this hard-wired list when it goes hunting for the Template to use for displaying a given bbPress page.
The $templates array includes the following Template file names (as of v2.2.2):
$templates = array(
'plugin-bbpress.php',
'bbpress.php',
'forums.php',
'forum.php',
'generic.php',
'page.php',
'single.php',
'index.php'
);
What’s important here is that the ORDERING of the Templates in the array matters, as the function bbp_locate_template() goes through this array sequentially and returns the first Template it finds, which gets used to display the bbPress page.bbp_locate_template() searches the Child Theme first, then the Parent Theme, and finally the theme-compat folder, so in theory one can install a Template in the Child or Parent Theme with one of the above Template file names, and so long as bbp_locate_template() finds it first, we’re all cool — that Template will get used for Forum pages.
There are 3 ways I can see to ensure my special Template is used when the Archive Base is displayed, in order of simplicity:
1. Edit the hard-wired $templates array in bbp_get_theme_compat_templates() in template-loader.php and add my template name to the top of the list. Of course, this is BAD PRACTICE since it will get overwritten in the next bbPress update, but a quick way to test out a Template.
2. Create a Template called “plugin-bbpress.php” and put it in my Child Theme directory. That’s the simplest.
3. Hook into bbp_get_bbpress_template, which is used as a filter on the $templates array and add my Template name as the first entry in the array. This is the way it’s intended to be done, from what I can tell.
All three of these will work, but they all have the downside of completely ignoring the Template setting of the Page Attribute for a given WP page (see here for what I’m talking about). For a given WP page that is “partnered” with a bbPress page, bbPress should use the Template specified in the Page Attribute. That’s what it’s there for.
While I haven’t tried it yet, perhaps I can hook into bbp_get_bbpress_template and inject the current page’s Page Attribute for the Template. I’ll have to dig into this a bit and see if it’s worth the effort. It seems like that would be the cleanest way, as well as in the spirit of how Page Attributes are supposed to be used.
Wish me luck.
Michael
November 25, 2012 at 9:33 am #120735In reply to: Is this what my first page is supposed to look like?
Pippin Williamson
ParticipantDid you setup the home page of the forums using the short codes? If so, switch to the HTML view of your page editor and you will be able to see the PRE tags.
November 25, 2012 at 9:21 am #120734In reply to: How is the forum archive page generated?
Michael
ParticipantOkay, I’ve been doing some digging and perhaps as expected, the theme Template page.php (the default WP Template) is being called to build the Archive Base page. I can edit the page.php in my child theme and customize from there (where it eventually calls the_content(), which apparently executes content-archive-forum.php to display the Forum “front page”), but that’s a brute-force method since page.php is the default Template for all pages. I want to create a Template explicitly for bbPress pages, which means I need a way to specify the Template to use on a per-page basis.
Normally this would be done by simply creating a Template (like page.php) and put it in your child theme directory, then select it for a specific page you want to apply it to using the wp-admin Edit Page -> Page Attributes -> Template pull down, save it and voila, your page uses your custom Template.
But with bbPress pages that are “partnered with a WordPress page” (per this topic discussion), this doesn’t work for the partnered page. The Template setting seems to be ignored, and only for bbPress pages partnered this way.
This may not be a show-stopper for me, but may be for others looking to customize the overall page Template for their bbPress pages. Is it a bbPress bug? I can’t tell, and hopefully I’m missing something painfully obvious, being new to installing/using bbPress.
Seems like there must be some kind of code frag in the plugin that does something like:
if (request to display (Archive Base | Topic Base) {
if ((Archive Base | Topic Base) is partnered with WP page) {
point the_content() at (content-archive-forum.php | content-archive-topic.php);
call default page Template;
}
}
JJJ or someone else in-the-know, can you comment on how the “partnering with a WordPress page” works? Where is this performed? Sorry if the question is naive, I’m just having trouble understanding how this partnering works at the Template execution level.
Many thanks.
MichaelNovember 25, 2012 at 7:00 am #120727In reply to: how to show user post count in 2.0.3
tomazi
Participanthow do i add the code correctly to the core?
is it
?I think its really wierd that bbpress does not have a easy way to add post count to the forum. Or is it something really easy i have missed?
Thanks!
November 25, 2012 at 5:49 am #120720John James Jacoby
KeymasterExactly like you’d expect:
- Create a page with the slug ‘topics’
- Use the ‘bbp-topic-index’ shortcode in the page content.
- Done.
November 25, 2012 at 1:13 am #120702In reply to: How is the forum archive page generated?
Michael
ParticipantFor what it’s worth, I’m looking for whatever function is calling content-archive-forum.php. I can edit this file in my child theme per the Codex, but I’m trying to figure out which function is calling this, and in particular, what function generates the code above the <div id=”bbpress-forums”> at the start of content-archive-forum.php.
Does bbPress simply use the default post display template, and if so, where is the call to load and execute content-archive-forum.php made?
I tried a grep for content-archive-forum in the entire wordpress tree from wp-content on down, and I can’t find where this is called from.
Many thanks
Michael
and not just this template file
November 24, 2012 at 11:06 pm #120698Topic: How is the forum archive page generated?
in forum TroubleshootingMichael
ParticipantHi there — I’m running WP 3.4.2, bbPress 2.2.2 & buddypress 1.6.1. Overall, I’m quite happy with the installation, and I’ve done a fair amount of customization on my site to give it a nice L&F. I’ve been using a child theme to do all customization, and it’s been reasonably straightforward, but not trivial. That said, many thanks to all the bbPress folks who are putting lots of time in on this plugin — it’s a great platform.
Onto my question: How is the main forum archive page generated? I want to create my own template to generate this page, and I’ve been stumped trying to trace the sequence of files/calls used to create it.
For context, I have the Forums Base set to “member-area/forums” in Settings -> Forums. I can go to http://mysite/member-area/forums and see the standard listing of all the forums in a table. Perfect, just what I want.
That said, how exactly is this page created? Which files & calls in the plugin create it? I’ve found loop-forums.php in …/plugins/bbpress/templates/default/bbpress/which is used to create the table within the page (apparently called as the_content() somewhere), but I can’t find the code blocks that create the header, footer, etc. Is there a single template page used to create the Archive Base page?
Apparently this page is generated regardless of whether there is an existing page (permalink) to the same permalink used as Archive Base. Nifty, but I want to use my own template (the whole thing) for creating the Archive Base page.
Even when I create a page with a permalink address the same as Archive Base and insert a [bbp-forum-index] in the post content, I can’t seem to select a Template from the Page Attribute pull down that has any effect on the creation of the Archive Base page. It’s like it’s hard wired to use a very specific template — that I can’t find in the directory tree.
Long winded, but I hope that conveys what I’m trying to do. In short, I just want to create my own template for creating the Archive Base page. Any pointers are appreciated.
Cheers,
Michael
November 24, 2012 at 8:11 pm #120693Pierre-Luc Auclair
ParticipantHi tzeldin88,
I had a similar problem. I am using various get_post_field calls to display parts of a footer that need to be editable by a client and needed to do apply_filters(‘the_content’,$x).
I have found that if I call
bbp_restore_all_filters('the_content',0);, it will bring the filter back, but it doesn’t affect the rest of the forum. 🙂 I would assume that calling thebbp_remove_all_filters()function after will disable it back.Hopefully my example here is clearer.
http://pastebin.com/BdiMFGTVNovember 24, 2012 at 7:52 pm #120692In reply to: bbPress 2.2.2 released
SK
ParticipantAs reported elsewhere, my theme doesn’t seem to like bbPress 2.2.2 either.
The problem caused is that I think the template files that make bbPress work with other themes broke.
I can still go to the forum pages with direct URLs or links in forum list widget, but the forums (list of forums or list of topics) are not visible. All I see in content area is page/forum title and forum description.
Similarly, on topic pages, I see topic title, but nothing else…
When I view source, the code is not there. e.g. when on forums home I view code, I can’t find the forum names (except in the forum list widget)
P.S. Reinstalling 2.2.2 has not resolved the issue.
-
AuthorSearch Results