WP and SMF bound by appearance only, by request.

Started by drewactual, July 10, 2018, 09:43:41 AM

Previous topic - Next topic

drewactual

Quote from: shinglis on July 10, 2018, 06:09:29 AM
Quote from: landyvlad on July 09, 2018, 09:54:57 PM
Quote from: drewactual on July 09, 2018, 01:59:13 PM

by the way... i don't understand the angst with WP... I use WP as the publisher as nothing anywhere else does as good a job from the users perspective, and i firmly believe SMF is the better of the forum engine softwares... they mate well- not in backend interaction, but can be styled to look the same to users, and that is the more important aspect.  a WP landing with information and a patch to comment in the forum is the ticket, in my humble opinion, and crucial to developing community...

Are you able to elaborate on this please? Perhaps in a new post - a how to or examples of matching a wordpress site and SMF site visually?.

I would also be interested in this discussion. Don't have the skill set for detail changes in CSS or SMF template but often wanted to combine features & plugins available in WP (nothing similar in SMF mods) to add features information to the overall site with the forum at the core.


prompted this (hopefully) brief discussion, and I drug it over here to keep that thread clear of a pretty significant hijack. 


brief explanation as to why I'm thinking WP is an important piece of a puzzle for those of us kick starting sites:

As i said in the 'other' thread, Forum's, it's been my experience, don't bring traffic without substance.  in this age of information being readily available the consistent 'fly trap' is content.  Content can be collected on a forum heck yeah- but by its very nature it doesn't have the 'authority' that publishing does... Publishing is better done with WP.  There are tools available to draft and launch and get your articles posting all over the web- which is significant for us SMF 'forum at heart' folks as we push our comments over to our forums.  If done strategically with tact, a community forms and boom- we're 'launched'.  enough of this, though.

WP is a simple engine/machine, too.  it's structure is easily deconstructed so folks like us can 'see what makes it tick', and this is useful for what i suggest is the easiest way to go about VISUALLY integration with SMF.  WP can be frustrating, though, when you see how authors have gone around their elbow to arrive at their arses with their coding, and while SMF authors cut to the chase.  both are well commented, though, and anyone with understanding of php and html can make this happen with little effort... oh, you can make it complicated let there be little doubt, but..... it's only as complicated as you make it.  complication, however, ought not be confused with 'time'.  if you want to do this right, it's going to take time.


prepping SMF:

SMF's magic is a simple templating process that rallies around the index.template in whatever theme you use.  there isn't much to it, really, but it's importance can't be understated as it frames the users experience.  for all practical purposes, the index.template get's the ball rolling insofar as required scripts and calls to CSS in it's head, and then throws out the header, followed by the body.  the 'bulk' is depending on what page you're requesting be it the index (entry) or a board (board.index) or perhaps the posts (display.index)- it all is 'framed' by the index template.  we want to introduce WP features, possibly, to this page so as to enhance the illusion of integration... this is done by adding to your smf/themes/theme/index.template a simple line that allows WP to operate 'outside the loop'. 

you'll want to add to your index.template

//Load WP  API
require '/home/user/www/blog/wp-load.php';


but... that just isn't good enough... first off, it 'requires', it doesn't just include... this means if your WP coughs, it takes SMF down with it.  so a better use is:

//Load WP  API
include  '/home/user/www/blog/wp-load.php';


it's better to do this as soon as you can... but it's also better to do this w/o interfering with SMF if possible.  after the magic SMF kickoff of:
function template_init()
and it's subsequent code, you'll want to plant the WP call... so let's just say:

before:
// The main sub template above the content.
function template_html_above()
{

add:

include  '/home/user/www/blog/wp-load.php';


boom... now you're ready to use some WP functions inside of SMF.  What you use is up to you.  It's important to notice the call to wp asks for the 'functions' and NONE of the theme elements such as templates and css.  you're going to want to add those lines too if you need them... let's say you do?  find in your SMF index.template the section in the header that requests css- and add an additional line requesting a look at your WP css.  Or, better yet, combine the CSS's and then minify them.... that's a topic for another discussion, though.

prepping WP to use SMF functions:

 
this is the difficult part... it's SO difficult, i recommend it be used only by experts with decades of practice.  for those of you bold enough to venture into this uncharted universe, know that the rewards are worth the effort.  here it is... in it's entirety... ready?

in your WP theme part that controls the head of the page, and before anything else is kicked off (first line), add:
<?php require("SSI.php"); ?>


this little line allows you access to a plethora of outputs of SMF functions... a list and how to do it is is here ....

another good idea to add to your WP file that controls the head is to call to your SMF theme's CSS. 

making them blend, blurring the lines, and where your time will be spent:


now we're down to talking about HTML, basically. 

right click your SMF homepage and look at the source code.  print it.  learn it.  break out the highlighter and color the major DIV#ID's, and DIV.classes... discover your structure in a building block fashion. 

do the same with your WP index.

break out a pencil and paper and draw out how you'd like the page to look... figure out the divisions you'll need to 'share' between the two... since you've called both CSS files in both SMF and WP, (or maybe you combined them and minified them?) you have access to their structure and presentation from both SMF and WP. whoop!!!!

you now get to toy around until you find a path that makes sense- hopefully one that doesn't make SMF rely on WP or WP rely on SMF (one doesn't break the other, and one of the reasons the preference is to 'include' rather than 'require' when/where you can). 


here is a spoiler and trick to consider:

both systems use templates.  why not jump in that party?

there are two ways to go about this... one is simple, the other more involved, but both work and work well. 

in separate directories located outside both SMF and WP, i have made (with success) php files with simple single functions.  as a for instance, there is one called 'display-header-page' and i'll give you one guess what it does? another that does sidebar adverts, for instance, and called 'display-sidebar-adverts'... guess what it does?  there is a display-footer, a display-this and a display-that... all of which combine to offer a page that looks just like the webpage but is void of content (other than what is added in those files)...

the involved manner to blend the two engines is to add lines in appropriate locations ON BOTH SMF index.template AND WP's 'header control file' such as:
<?php include('.././overarching-site-template-files/display-header.php'); ?>

the simple manner to achieve the same thing is to destroy anything and everything to do with the index.template and the wp's template output's controls FRAMING, and build your own.... an absolutely rudimentary example is something like this for both WP and SMF:

in your SMF index.template, and right after the head closing tag (/head) add something like:

<?php include('.././overarching-site-template-files/display-header.php'); ?>


and right before the closing of html (/html) add something like:
<?php include('.././overarching-site-template-files/display-footer.php

obviously, in between at various locations you'll want to add your external include for sidebars, ect. 

you'll do the same thing for your WP template files. 

the include files will contain your 'form', NOT your 'function'.  the function remains with the engines, be it WP or SMF.   you're going to want to remove as much style and 'form' from both SMF and WP as you can, and control them with your own external 'site-template' files.... basically, you're building a template system that's all your own using simple php includes and html outputs from within those php files, and forcing SMF and WP to operate inside that framework, and without screwing with the functions of either SMF or WP.... you can absolutely use functions 'outside the loop' for WP functions inside SMF, or use SSI to add output of SMF functions inside of WP- but i recommend you do that sparingly so as one is limited in its ability to 'break' the other. 

if done right, it's seamless.  users just won't know.  the 'giveaway' on my site is the top bar where the cookies (login) don't translate from WP to SMF or vice-versa.....





some good functions from WP to use in SMF (or better yet one of those external php files called into SMF in the index.template) :


~open your html output constraints here such as controlling (visually) div's, spans, ect~
<?php
function get_post_excerpt$post_id$excerpt_length null$excerpt_more null$more_link true ) {
$post get_post$post_id );
if ( null === $excerpt_length ) {
$excerpt_length apply_filters'excerpt_length'55 );
}
if ( $post->post_excerpt ) {
$excerpt $post->post_excerpt;
} else {
$excerpt strip_shortcodes$post->post_content );
$excerpt apply_filters'the_content'$excerpt );
$excerpt str_replace']]>'']]&gt;'$excerpt );
$original_word_count str_word_countstrip_tags$excerpt ) );
$excerpt wp_trim_words$excerpt$excerpt_length'' );
$is_trimmed_excerpt str_word_count$excerpt ) < $original_word_count;
}
if ( null === $excerpt_more ) {
$excerpt_more apply_filters'excerpt_more''&hellip;' );
}
$excerpt_more = empty( $is_trimmed_excerpt ) ? '' $excerpt_more;
$excerpt apply_filters'get_post_excerpt_excerpt'$excerpt $excerpt_more );
if ( false === $more_link ) {
return $excerpt;
} else {
$more_link sprintf'<a href="%s" class="more-link read-more-link">%s</a>',
get_the_permalink$post->ID ),
apply_filters'get_post_excerpt_read_more_text''Read More' )
);
}
return $excerpt apply_filters'get_post_excerpt_read_more_link'$more_link );
}
?>

~close your div's here~
<?php wp_reset_query(); ?>


this will add a WP post to an SMF page, or to the page (is it your site-template framework?) you call it to. 



anyway, this has been a down and dirty explanation to follow up on the two folks who asked.  I hope it helps others, and i'll be happy to answer any questions if there are any. 

to see how i blended a page of mine, follow the link in my sig- SMF is up front in this instance, and the 'publisher', i.e WP, is available in the top menu.


vbgamer45

Thanks for the guide. Should help a bunch of people
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

confuseamuse

Quote from: drewactual on July 10, 2018, 09:43:41 AM
if done right, it's seamless.  users just won't know.  the 'giveaway' on my site is the top bar where the cookies (login) don't translate from WP to SMF or vice-versa.....

Can't you use SSI to solve that problem?

drewactual

Quote from: confuseamuse on July 10, 2018, 12:05:36 PM
Quote from: drewactual on July 10, 2018, 09:43:41 AM
if done right, it's seamless.  users just won't know.  the 'giveaway' on my site is the top bar where the cookies (login) don't translate from WP to SMF or vice-versa.....

Can't you use SSI to solve that problem?

i can, but i don't see it as a problem... if it were something of concern in my application of this merger, it would grant access to both SMF and WP via one login- or the bridge, if you would... i don't want a bridge... the two engines provide a distinct function as i'm presenting it.  there is no need for SMF users to have access to WP in this case, and contributor's are aware they have to log into the publisher to fiddle there. 

this time of year, again in my personal application, there is only one original WP post published, as everything else there is aggregated articles... that will change in the coming weeks as the season approaches.  for that, instead of being overly complicated about it (I could make a script that opens a new SMF thread/topic for every specific category of WP post automated) i simply post up the article (or a contributor does) and then post a link to a pre-positioned SMF board and topic to support it's comments....

the single original article posted now is super long so i didn't do it in this instance, but a copy of the article in the opening topic post, as a practice, is helpful or users to pick it apart in the comments (using quote).   

 

Arantor

Other than two systems that both require patching, and a not entirely fluid experience between the two, what does this give you that a portal can't?

Kindred

and, if you say "a blog" - let me point you to Sesquipedalian's site....
https://www.simplemachines.org/community/index.php?topic=558772.0

all done within SMF.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

shinglis

Thanks for this. Have you had any experience with WP packages or just the core features.  I'm guessing is the packages setup on a WP page then the page integrated should work.

drewactual

Quote from: Arantor on July 12, 2018, 08:10:39 AM
Other than two systems that both require patching, and a not entirely fluid experience between the two, what does this give you that a portal can't?

tools.  like it or not WP is the widest used open source engine on the web.  there are tools galore, but more importantly (in my case) it's the portability.  i can connect with other WP sites and swap articles, share links, trade lists, and all automated as they are using WP and there is a tool for it- where as SMF can't do that (or it hasn't been developed to my knowledge) and there are only a small fraction of SMF sites as compared to WP- making 'share' transactions easier.  With WP I can (and have/do) run full out stores with resident cc processing and presentation 'out of the box' where as any SMF shop looks like it came out of the nineties without tons of effort coding php and css.  WP has tools that auto-post to social media and updates as the user dictates, automatically, and in a format prescribed by the admin- SMF doesn't have anything approximating that i've encountered.  it could be done, yeah, but- i could either spend my time and effort drafting such a thing (which is pressing any semblance of skill i have with such matters) but 'out of the box' WP has it.  I can even post items for sale on social media using tools already available via WP.  and possibly more importantly, i can pull from API's entire current/updated product listings complete with images and prices adjusted for my retail margin using well tested and validated, not to mention thoroughly supported, plugins for inventory management and automated ordering from those distributors- making a webstore an upfront effort on my part, and requiring only mild management/supervision once bugs are kicked out of it..... again... out of the box. 

don't get me wrong... I'd much rather be able to do all of this with just one engine.  SMF can't do it.  Until there are substantial 'listeners' for original content offered by my writers ensuring their articles get as much publicity as possible, which would have to be designed in a manner the metadata is in the right place as well as images and text itself- which is the default of WP... again, because of the sheer widespread use of WP, all newsreels accept post/articles as-is straight out of the hopper.  the last thing i need is some clumsy script that imitates WP output to goof, and getting the articles blackballed by the distributor.

insofar as i am concerned, there is no better forum than SMF.  for enterprises that rely heavily on community, SMF will always be the choice for that support.  on the page i most often goof around with, the 'community' (aka forum) is the primary driver.  without it, the page would be nothing.  the extreme value of that particular forum which is something i inherited due to a bankruptcy of a major company and CBSInteractive buying them out of chapter11- basically handing me the forum aspect of the original... i know the crowd well- for more that 17 years- and i know their interests and hobbies... it allows me to secure vendors that cater to their interests, launch a website selling said items/families of items, and direct market to them.  the power of community cannot be understated- and SMF is the glue that keeps it together.  It also allows me to advertise for affiliate markets, which basically covers my operating expenses of leasing a dedicated server.  read: one site and it's traffic, which is a community/forum, pays the overhead for the entire operation.  THAT is something WP CAN'T do, and it would be extremely------ optimistic----- to ever attempt such a thing with WP. 

edited to add: this isn't just a guess, either... google analytics demonstrates a bounce rate of 17% overall for my primary community, and an average session of exceeding ten minutes for the core forum... i don't and have never owned a WP site that has anything better than a 40% bounce rate, and an average session exceeding 90 seconds... however, for entry into my pages that weren't direct linked, WP rules by a wide wide margin. 

you asked what it gives me a portal can't... ^that.


Quote from: Kindred on July 12, 2018, 08:41:04 AM
and, if you say "a blog" - let me point you to Sesquipedalian's site....
https://www.simplemachines.org/community/index.php?topic=558772.0

all done within SMF.

I've been watching that thread for some time- and the work accomplished there is impressive and presented in a very tasteful way.  they gots skillz, yo.  I love how the boards are almost a 'second thought' like "oh yeah- here is a place to talk it up!" after rendering their mission statement and cause... very nicely done.  However, in the case i find myself, I want the forum to be just that- straight forward and easily found, navigated, and used.  Likewise i want the 'publisher' (in one instance) to be the defacto purpose of its page.  The store, likewise... all of this has purpose, but for an operation like Sesquipedalian's?  It's perfect, and a true thing of beauty.

drewactual

Quote from: shinglis on July 12, 2018, 09:45:29 AM
Thanks for this. Have you had any experience with WP packages or just the core features.  I'm guessing is the packages setup on a WP page then the page integrated should work.

by plug-ins I am assuming your speaking of things that will render totally different such as a store? 

i guess it really doesn't matter if that is it, but... i've gone through every output and matched enough that the rendering is almost transparent to the user.  that includes the core package and all themes and plugins.  usually, i choose a theme that has the basic structure that will compliment, and make a child-theme out of it... then i chop the crap out of the child until it renders how i'm happy with it. 

i offered up earlier that you can make your own CMS and force WP and SMF to operate inside of it, but.... I most often choose not to do that instead just making the sites render very similar via themes.  not only are all my instances where these are 'shared' running on different db's, but i want them as stand alone as possible in the case an update to one or the other disrupts what i'm trying to accomplish.

landyvlad

Re-reading some old threads, and wondering whether the code info in this thread would be equally compatible with SMF 2.1 ?
"Put as much effort into your question as you'd expect someone to give in an answer"

Please do not PM, IM or Email me with questions on astrophysics or theology.  You will get better and faster responses by asking homeless people in the street. Thank you.

Be the person your dog thinks you are.

Biology Forums

I once had wordpress and smf meshed together. It's annoying to keep updating both, where if you make a style change on SMF, it also needs to be made on wordpress, for example Wouldn't go back to that, waste of time and resources

drewactual

Quote from: landyvlad on January 02, 2019, 12:24:42 AM
Re-reading some old threads, and wondering whether the code info in this thread would be equally compatible with SMF 2.1 ?

much of this is done independent of either WP or SMF, so... it shouldn't change much if at all.

Quote from: Study Force on January 02, 2019, 12:47:00 AM
I once had wordpress and smf meshed together. It's annoying to keep updating both, where if you make a style change on SMF, it also needs to be made on wordpress, for example Wouldn't go back to that, waste of time and resources

it all depends on what you're looking for... On one site (one in my signature) i've found that the WP usage is mostly from mobile devices, so i curtailed the all out 'magazine' presentation and left it simple- the 'visual integration' part is just enough to know it's the same parent site.   I guess you could dive deep into it if you wanted, but i've also found that WP is somewhat feeble in some regards, especially 'outside the loop'- and for that reason there are only two instances of it's use on my 'main' home page (SMF)... At one time, when there was a store running on that site, instead of articles i used product's... on another site, it still works that way but the WP is the main engine and the forum is a peripheral to it. 

Woocommerce on WP is more powerful than any cart for SMF is the reason... it's just a mater, at that point, of using the WP framework in 'includes' for SMF- basically the 'header' php, the 'sidebar' php, and the 'footer' php.... to make it even simpler, the WP theme is altered to where the 'sidebar' php and 'footer' php is combined- meaning SMF's 'index.template' just has to be stripped of items that conflict and an include 'above body' and 'below' has to be made... it then 'appears' to be integrated.   

if there were any coding's to change, and it's just not that important at this time to consider, I'd like to see a function custom made that automated and opened an SMF thread for each article/product introduced in WP, and a link to 'discussion' as opposed to WP's 'comment' section... I could see some use for that.  but as it is.......... keeping them apart except for appearance seems smarter, as one doesn't take the other out if it trips over itself.     

Biology Forums

Do you have a working example where you've combined the two?

drewactual

no... not truly 'combined'.  cfb51 (signature) is an example of 'sharing' (the main page is SMF, the 'publisher' is WP accessed either by sidebar on the 'articles' or by the nav bar... i used to have user information via SSI atop the publisher's(WP) sidebar as it is in the SMF page, but i think it caused confusion with users trying to use the WP comment section (which i turned off altogether also as a result of that and just leave a link to the articles' comments in SMF). 

'visually' integrating these is solved by providing the 'framework' to the same external files.  It requires you perform surgery on both the WP theme and the SMF theme to include the external files that produce the 'skeleton' of the pages presentation, and while removing the redundancy if there is any.  then add simple includes to those files in both WP and SMF so they 'look' like they're the same 'theme'.

if SMF is the only place benefiting from users being logged in (which is my case in just about every instance), I don't worry about actually 'combining' or 'bridging' the two (sessions/cookies-functions other than SSI/Outside the loop articles/products).  A splattering of SSI on the WP pages and a touch of 'WP outside the loop' articles/products on/in the SMF adds to the experience the two are combined, but they actually are not- they just share the same 'theme skeleton' for lack of a better term.


Korotana365

******After the Final No is a YES!******

drewactual

Quote from: Korotana365 on January 16, 2021, 11:37:16 PM
Any sample sites using this method?

sure, if the mods will allow the link.. here is one i'm just now launching and using 2.1- i'm still some time from passing it off to it's owner, but it's close.  it uses a woocommerce store, the blog of course, and the forum.

https://www.angry-patriots.com

drewactual

the afore mentioned site is getting real close to going active... i have some cleaning up to do here and there... but..

you can see how the site flows even though both systems are despair.... basically i used SSI on the WP side, and used WP includes on the SMF side... on the SMF side, which will see most the traffic once i port the folks over there, i have both products from the woocommerce install listed in a sidebar, and auto fed articles below the boards/threads/posts. 

i'm not saying this is optimum, but, it looks good enough and it brings the might of WP to bear when it comes to publishing and publishing tools which is something SMF can't do (it can look damn good, but it doesn't have the backend support for 'broadcasting' that WP does- nor should it).

Advertisement: