Posts Tagged ‘Concrete 5’

Concrete 5 SQL errors during installation

Friday, February 3rd, 2012

We have seen this error with Concrete 5.5.1

You try to setup Concrete 5, and get strange SQL errors during the installation:

If installing with an empty site, like this

c5-nosample-content-chosen

you get:

c5-mysql-error

mysql error: [1048: Column 'uID' cannot be null] in EXECUTE("INSERT INTO Config (cfKey,cfValue,uID) VALUES ('NEWSFLOW_LAST_VIEWED','FIRSTRUN',NULL)")

If installing with Sample content with Blog:

c5 with sample content

The error you get is:

Catchable fatal error: Argument 1 passed to ContentImporter::importPageAreas() must be an instance of Page, boolean given, called in /concrete/libraries/content/importer.php on line 75 and defined in /concrete/libraries/content/importer.php on line 197.

 

Solution:

You don't run Varnish by any chance, do you? We do, and we had it set up to … dispose of some cookies. The solution is, in Varnish' case, to enable pass-through for the host you are installing on.

You want to enable cookies.

 

Explanation:

The code which breaks is located in concrete5.5.1\concrete\models\package\starting_point.php

Config::save('SITE', SITE);
Config::save('SITE_APP_VERSION', APP_VERSION);
$u = new User();
$u->saveConfig('NEWSFLOW_LAST_VIEWED', 'FIRSTRUN');

As you see, this is the first time a User is created and used.

The User class is defined in concrete5.5.1\concrete\models\user.php

if (isset($_SESSION['uID'])) {
$this->uID = $_SESSION['uID'];
$this->uName = $_SESSION['uName'];
$this->uTimezone = $_SESSION['uTimezone'];
if (isset($_SESSION['uDefaultLanguage'])) {
$this->uDefaultLanguage = $_SESSION['uDefaultLanguage'];
}
$this->superUser = ($_SESSION['uID'] == USER_SUPER_ID) ? true : false;
} else {
$this->uID = null;
$this->uName = null;
$this->superUser = false;
$this->uDefaultLanguage = null;
$this->uTimezone = null;
}
$this->uGroups = $this->_getUserGroups();
if (!isset($args[2])) {
$_SESSION['uGroups'] = $this->uGroups;
}
}

The constructor checks in the Session for a valid user ID. If no user ID is found, it is set to zero. This happens if you throw away the cookies! Because the session is stored in them.

HTH. Feel free to comment on similar errors and solutions.

Redirection with Concrete 5

Wednesday, September 14th, 2011

URL Shortening is all the rage now. Sometimes you want to give people ridiculously long URLs, which might also be subject to change.

So you want to do it with C5, don't you?

Great, you think – there's the "add external link" menu option in Concrete's sitemap. Unfortunately it does not work the way you expect it to – it just adds the link to the Navigation, but no page alias to point to the external page (i.e. http://www.synapse-redaktion.de/FaceBook won't work after adding a "FaceBook" external link).

What to do to solve this dilemma?

My suggestion is to use both: add a (hidden) page "FaceBook" which does header JavaScript forwarding to the other page, so you can give out the links to the people, and a "real external link" so you don't have to rely on JavaScript for most of your visitors.

The SiteMap will look like this:

sitemap

Adding custom attributes: (Header Extra Content, Exclude from Page List, Exclude from Nav)

header extra content

The page's setup:

setup

The script is easy:

<script type="text/javascript">
<!–
window.location = "http://www.surfnext.com"
//–>
</script>

with surfnext.com being the URL you are forwarding to.

If you have the time, you might want to add a static link or icon to the page (/*comment*/ the window.location = … part to be able to edit the page!) in case some person has their JavaScript turned off.

Privoxy rules to unblock Concrete 5 editing

Friday, May 20th, 2011

In Concrete 5, TinyMCE is used as an editor for Content blocks. If you have Privoxy installed with the default settings, crucial parts of this editor will be blocked, and you would be unable to edit the Content block properly. (no editor appears, you see a small box with the HTML instead).

You can verify that it's indeed Privoxy which is doing it, by checking the Network tab of Dragonfly or Firebug in Opera or FireFox, Privoxy will add a status message to files which have been blocked.

To fix this problem, edit your user.action file (located in the application's toplevel directory), and add a new line under the { fragile } section:

{ fragile }
#.forbes.com
/concrete/js/tiny_mce/plugins/.*
/updates/concrete.*

This should unblock all Concrete 5 – based sites.

Update (23.10.2011): The fix now works with updated Concrete 5 sites.

Concrete 5 behaving weirdly

Sunday, May 8th, 2011

The problem

Suddenly you can't edit your content blocks anymore – Concrete 5 shows them in HTML. Also you can't save properly, and page content becomes disordered, some blocks are missing after saving. This seems to happen in several browsers.

The solution

You may have a proxy server software or something similar which blocks some JS scripts Concrete needs to process the page correctly. In my case, Privoxy was the problem. After I turned off the proxy settings in my Firefox, I could edit the page normally. Of course I had Privoxy enabled in the other browsers I was testing the site with, too.

Btw, Privoxy is a great and free software to reduce the "noise level" while browsing by blocking "unnecessary" third-party content on webpages (read advertisements. I know, it's a philosophical question for some other time.)

Developing with Concrete: New Block Type not showing up

Wednesday, November 17th, 2010

Problem: you are adding a new block type to your package. You are updating the package using Concrete's update functionality, but no new block type shows up.

Solution: remove the package completely (uninstall – but leave it in the package directory, when C5 offers to move it to trash!), and install it again. Your block type should show up now.

PDFGenerator for Concrete 5

Sunday, May 2nd, 2010

After Georg (below) commented, I felt inspired to polish the code into usable Alpha state.

IdeaDay PDF Generator (v3.0 Alpha)

This Concrete 5 package encapsulates mpdf and makes it easy to create PDF versions of your pages.
It was written by ideaday.de
Contact: http://www.ideaday.de/kontakt

mpdf was written by Ian Back (it makes itself heavy use of other OSS projects).
We use Version Version 4.4, released 24/03/10

See the other files for Licensing and Version information. (This blog entry is just a formatted README.txt)

Download

Get your package here:

Installation

1) download the ZIP
2) unzip it
3) upload the folder ideaday_pdf_generator in your packages folder
4) install it using the Dashboard

Usage

Add an Icon / link to the page(s) you want to generate the PDF from, including the query parameter ?ipg_mode=pdf
i.e. http://www.example.com/this/is/a/page/?ipg_mode=pdf

Feel free to edit the default settings in /helpers/pdf.php:
$options['ipg_filename'] = 'website.pdf';
$options['ipg_mode'] = 'I';
$options['ipg_header'] = ";//'{PAGENO}'; //You could set up your own header here.
$options['ipg_footer'] = ";

To modify the way the PDF is shown (streamed / forced download) you currently have to edit the line
$pdf->showPDF();
and change it to the appropriate function.

Functions

public function getHTML()
Returns the actual HTML used to build the PDF.

public function getPDF()
Returns the PDF as a string.

public function streamPDF()
Streams the PDF.

public function showPDF()
Displays the PDF in the browser

Known limitations

  • Floating images are rendered on top of the text instead floating beside it. If you specifically set the image size in pixels (IMG width / height), it will render correctly.
  • I have exposed only a very limited subset of the MPDF package, i.e. it renders in DIN A4, instead of letter, etc.
  • You have to add the icon/link, and tweak the source to change settings. I plan to add a block which will display a link and allow you to set up settings on each page individually.