Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-01-16 14:32:54

blogling
Member
Registered: 2020-01-16
Posts: 12

Integrate Textpattern in existing site

Hi there,

Moving away from another cms I am interested to know, if and how I can integrate Textpattern inside an existing db-driven website, whereby the header and footer sections of the existing site should stay visible.

Thanks
blogling

Offline

#2 2020-01-16 15:27:29

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Integrate Textpattern in existing site

blogling wrote #321131:

Moving away from another cms

Wise choice. ;)

I am interested to know, if and how I can integrate Textpattern inside an existing db-driven website, whereby the header and footer sections of the existing site should stay visible.

I think what you are asking, if not mistaken, is if there is an import script to get your existing dump file and site structure into Txp?

Development on that sort of thing hasn’t happened for a while, that I’m aware of, but there might be something. Even if there was, it wouldn’t be a flawless execution; you’d still have to tweak and fix a few things, undoubtedly.

But you can certainly put up a dev location of Txp and recreate your current site structure and presentation in Txp, and probably with not too much trouble. The real question is, how much content do you have in the current website and expect to import via the other DB dump file.

Offline

#3 2020-01-16 15:49:24

blogling
Member
Registered: 2020-01-16
Posts: 12

Re: Integrate Textpattern in existing site

Bonjour Destry,

No, not quite. Sorry I was not clear in explaining: We have a running, custom-made website (all coded by us internally – php, css, and a complex mysql db with dozens of tables, etc.). And now I should add a light-weight blog as an extra item. It would replace our current “News” menu item which is an external blog cms (but which is quite heavy and slows down performance:

About us – Our products – Blog – Contact

Textpattern should just work inside the existing site in the ‘Blog’ section, but when the blog is called the existing menu (header) and footer should stay as they are.

There will be no importing of information. The blog can be empty on install.

Offline

#4 2020-01-16 16:31:15

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Integrate Textpattern in existing site

I see. Thanks.

Well, a true integration as I suspect you mean is over my pay grade. Maybe others might have the insights to know what to suggest.

What others often do in this case, as you are probably aware, is install Txp in a ‘blog’ subdomain (e.g. domain.tld/blog/). So you would essentially have two systems to log into and two different DBs to manage.

But then you just replicate the presentation in both places, easy enough, and adjust the navigation menus in each case so they point to the right locations. The general public just sees it like a common/universal menu across the board.

You could even use the same set of stylesheets, etc, to manage both locations.

Offline

#5 2020-01-16 16:34:28

blogling
Member
Registered: 2020-01-16
Posts: 12

Re: Integrate Textpattern in existing site

Yes, that is exactly it. With the current blog we use, we had massive issues getting our own menu and footer override what the blog cms was offering. Hope that with Textpattern it will be easier. We’ll give it a try and see how things come out.

Offline

#6 2020-01-16 16:47:01

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Integrate Textpattern in existing site

Let us know how it goes. Txp will not constrain you from anything. You code/design it as you want it to be. I’m sure others here have this very thing setup somewhere, so any questions later, just ask.

Offline

#7 2020-01-16 17:44:47

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,578
Website

Re: Integrate Textpattern in existing site

Hi blogling. If you install Textpattern in the /blog subdirectory it can operate independently of your other site. As Destry said, you’d have separate logins but I think you were expecting that.

In your Textpattern page template, you could use the txp:php tag to include your menu and footer from your existing site (provided you have them appropriately modularised in your own site) and only need do the news article navigation in Textpattern. You may need to inform your included menu that you are on the blog section so that you can style the menu item’s active state, but that could be as easy as setting a variable before your include.

Otherwise, you are pretty free with the markup you want to create using Textpattern, so you could make it emulate your current blog styling and use your site’s central stylesheet as before.


TXP Builders – finely-crafted code, design and txp

Offline

#8 2020-01-17 22:19:13

blogling
Member
Registered: 2020-01-16
Posts: 12

Re: Integrate Textpattern in existing site

Basic installation in a folder ‘blog’ was a breeze. Now our existing basic global page set up for headers and footers in both mobile and full screen goes something like this and I have not figured out yet, how to transfer this to Textpattern:

<head>
<link href="css/custom.css" rel="stylesheet" type="text/css"/>      
</head>

<body>
        <?php include 'helper_mobilesidebar.php'; ?>   <!-- mobile SIDEmenu -->
        <?php include 'helper_detailsearch.php'; ?>        <!--  mobile SEARCH SIDEBAR -->
        <?php include 'helper_mobiletabs.php'; ?>            <!-- BOTTOM TAB BAR  -->

            <!-- BIG CREEN TOP MENU-->
      <div class="mobileNO"> 
         <?php include 'helper_bigscreenmenu.php'; ?>
      </div>

        <!--START MOBILE BODY -->
      <div class="body-mobile ">
            <?php include 'helper_headermobile.php' ?>
      </div>

      <!-- content -->
      <div>  page content </div>

      <!-- at end of body -->
                <?php include 'helper_footerbigscreen.php'; ?>

</body>
<!-- open+ close left and right sidebars mobile -->
<script>
    function driveNavs() { .....
</script>

Do I understand correctly, that under Textpattern -> Presentation -> Pages I need to create a new ‘default’ page to then include the above somehow?

Gosh, I love my newbee questions :)

Thanks

EDIT: Added bc..{space} to code block.

Offline

#9 2020-01-17 22:48:03

etc
Developer
Registered: 2010-11-11
Posts: 5,028
Website GitHub

Re: Integrate Textpattern in existing site

blogling wrote #321208:

Do I understand correctly, that under Textpattern -> Presentation -> Pages I need to create a new ‘default’ page to then include the above somehow?

Gosh, I love my newbee questions :)

You learn quickly :-) Yes, basically what you need is

  • create a new Page (or replace default) with your code (modify include paths if needed)
  • replace <?php ... ?> blocks with <txp:php> ... </txp:php>
  • put something like <txp:article><h3><txp:title /></h3><txp:body /></txp:article> where you want the content to be output
  • assign this new page to some Section and publish few articles within this section
  • test

Offline

#10 2020-01-17 22:49:26

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,578
Website

Re: Integrate Textpattern in existing site

Yes, that’s the basic principle. If you want to keep the existing theme for reference, you might want to start by:

  1. Go into Presentation › Themes and duplicate the existing theme. Give it a new name for your own site.
  2. Now go into Presentation › Sections and assign the new theme to those sections.

That gives you something to play around with without losing the standard setup. You can then refer back to that as needed.

In Presentation › Pages, make sure your new theme name is selected and choose the default page template.

You’ll want to enter something like this and save it:

<!doctype html>
<html class="no-js" lang="">
<head>

<!-- see the existing default template for textpattern tags for the head area -->

<link href="/path/to/css/custom.css" rel="stylesheet" type="text/css" />      
</head>

<body>
<txp:php>
    global $include_path;
    $include_path = '/path/to/your/includes/';
    // mobile SIDEmenu
    include $include_path . 'helper_mobilesidebar.php';
    // mobile SEARCH SIDEBAR
    include $include_path . 'helper_detailsearch.php';
    // BOTTOM TAB BAR
    include $include_path . 'helper_mobiletabs.php';
</txp:php>

      <!-- BIG SCREEN TOP MENU-->
      <div class="mobileNO"> 
<txp:php>
    global $include_path;
    include $include_path . 'helper_bigscreenmenu.php';
</txp:php>
      </div>

        <!--START MOBILE BODY -->
      <div class="body-mobile">
<txp:php>
    global $include_path;
    include $include_path . 'helper_headermobile.php';
</txp:php>
      </div>

      <!-- content -->
      <div>

      <!-- this is where you put your textpattern tags 
           see the existing templates for reference -->

      </div>

      <!-- at end of body -->
<txp:php>
    global $include_path;
    include $include_path . 'helper_footerbigscreen.php';
</txp:php>

</body>
<!-- open+ close left and right sidebars mobile -->
<script>
    function driveNavs() { .....
</script>

You’ll need to use textpattern’s own tag system for the head area and main content area in order to output the content you enter in the blog and to get page-relevant head metadata such as page title, canonical url and so on… If you look at the default template, you can see how it’s done.

The includes are just an example. You can either set a global variable to use for the path or simply adjust your includes and css link to include the path to your original files. For this to work, your existing includes must be relatively self-contained, i.e. be able to function independent of other contextual information that textpattern doesn’t have access to.

If you want your menus to be highlighted when active, you might want to add a variable $this_page = 'blog'; (or whatever) that you pick up on in your included menu to denote the current location.

EDIT: Hehe, etc was quicker and more succinct (as ever).


TXP Builders – finely-crafted code, design and txp

Offline

#11 2020-01-17 22:50:19

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: Integrate Textpattern in existing site

Yep, exactly. Make your ‘default’ Page template a copy of the above. Just replace:

<?php include... ?>

with:

<txp:php> include...</txp:php>

And then in your <div> page content </div> put a <txp:article /> tag with suitable parameters to display your list of blog articles. They should be automatically clickable using the default Form content and each link will lead to its individual article. If not you can use it as a container tag and/or employ some conditional logic such as: <txp:if_article_list> ... <txp:else /> ... </txp:if_article_list> to branch based on whether the URL represents a list or an article.

You might want to set your permlink scheme to just ‘/title’ from Admin->Preferences, unless you plan on having different sections to your blog.

EDIT: Haha, Oleg and Jools were quicker than me :)

Last edited by Bloke (2020-01-17 22:55:52)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#12 2020-01-17 22:53:07

etc
Developer
Registered: 2010-11-11
Posts: 5,028
Website GitHub

Re: Integrate Textpattern in existing site

jakob wrote #321211:

Hehe, Oleg was quicker and more succinct (as ever)._

The more the merrier :-)

Offline

Board footer

Powered by FluxBB