12

Craft’s bootstrap file in located at craft/app/index.php. Importing that will get you 99% of the way there. The only problem is, index.php not only loads Craft, it also runs it. In doing so, Craft is going to insist that it completely resolves the request, with a response to the browser. I’m thinking we should move most of that code into a new bootstrap....


7

That's how I do it, not sure if there's an easiest way... Just call header and footer via include > /craft/templates/index.html {% include '_header' %} ...your content goes in between... {% include '_footer' %} Then load bootstrap CSS on craft/templates/_header.html <link rel="stylesheet" href="/css/bootstrap.css"> Same with craft/templates/...


3

That bootstrap file is only meant to be used by web applications. Even if you got past this error, the file is still going to give you a WebApp instance, when what you really want to be working with in that environment is a ConsoleApp. If you want to load Craft from the command line, use craft/app/etc/console/yiic instead (make sure it has executable ...


3

For running Craft from the console you just need to copy all the content of /directory/toCraft/app/index.php to another file, called what you want. Comment the last instruction $app->run(); and finally add this instructions in the beginning of the file: $_SERVER['DOCUMENT_ROOT'] = '/some/path/to/craft.dev'; $_SERVER['HTTP_HOST'] = 'craft.dev'...


3

$entry->featuredImage[0]->getUrl('small'); works.


3

If you're doing it from a custom bootstrap script, you'd need to do something like this for plugin logging to work: $craft = require '../craft/app/bootstrap.php'; craft()->plugins->loadPlugins(); MyPlugin::log('My Message', LogLevel::Error); craft()->end();


3

The instances would all share the same database instance since we don't store any data in the database anyways so that wouldn't be an issue... Brad or Brandon from P&T is probably going to chime in here with a better answer but it sounds like more trouble than it's worth. For one thing, Craft relies on the database to determine if plugins are enabled ...


3

So to close the loop on this one, I actually ended up using a different grunt tool that essentially accomplishes the same goal called purifycss. I was able to target purifycss at the craft template folder, get it to look at bootstrap css selectors actually in use in the templates, compare it to the full bootstrap css files, and then have it output only the ...


3

Why not use: {% if block.sidebar|length %} <div class="col-sm-8"> {% else %} <div class="col-sm-12"> {% endif %} This way the column will automatically be smaller IF the side bar exists.


2

It looks like you can check for the total number of blocks within a matrix block. So if you check that the length is greater than 0, you could then apply the classes. {% if entry.myMatrixField|length > 0 %} <div class="col-sm-4"> // other code </div> {% endif %}


2

I don't use Foundation 5. I've been using Foundation 6, but I'll offer a suggestion based on Foundation 6 usage. It looks like your Foundation CSS is overriding the base Craft control panel CSS, specifically the button classes. My guess is that because you're including all the Foundation classes available. If you're using the SASS version, you can ...


2

I read that you cannot use bootstrap.php in the craft/app folder because you're essentially trying to bootstrap a webapp (and this server isn't a webserver). Not sure where you read that, but that doesn't sound right. I'm assuming you've got a multi-environment config setup? If so, then manually set the CRAFT_ENVIRONMENT PHP constant before you load the ...


2

With some help from HendrikEng's answer I figured out something that does work. I had to make the batch bigger to an amount of 5 making the "row's" bigger. Also I had to set the position of the bigger block which always is the first or second of this batch so I could set this witha variable which changes if a new batch started. This is the finalcode which ...


2

It shouldn't be that slow to bootstrap, but even if you're not doing anything with the plugins in your template, they are still loaded and instantiated with every request. If I were you, I'd do some profiling with Blackfire or NewRelic to see what's really going on.


2

I'd break up the forloops a bit so you're outputting the panel container and the accordion wrapper markup once. Then for each accordion (supertable row) you're outputting that markup as many times as it's needed. I haven't used Bootstrap JS packages for a long time, so I was a bit thrown by the amount of divs you have. (I use this accordion package for how ...


2

A matrix field for an image carousel needs only a single asset field, one that will accept more than one image. In my experience there is rarely a requirement for anything more. 99% of carousels I have implemented look like this: If you wanted to add text to accompany each slide you could add a text field directly to the image asset and then display that ...


2

I'm not entirely clear what your Matrix blocks/fields are setup like, so it's a little hard to tell what's going on here. But I'm going to take a stab at it. Your outer loop is looping through all the blocks in the calendarGroup Matrix field. Then you're using a switch to determine which piece of code to execute based on which one of the two block types ...


1

You could track the total used columns in a var and check if its less than 12. {% set col_count = 0 %} {% for item in items %} {% switch item.type %} {% case "value1" %} {% set col_size = 4 %} {% case "value2" %} {% set col_size = 6 %} {% endswitch %} {% if not loop.first and (col_count + col_size) > ...


1

So debugging this a bit, it looks like its to do with the namespace declaration on the original template I was using for the migration. Basically when declaring namespace Craft this causes problems with loading the environment variables that were previously being masked by the die() error, as I was including Bootstrap too early. Uncaught Error: Class 'Craft\...


1

I do things mostly the same way leowebguy does. I'd just add a comment on his, but I don't have enough points yet. I've got a _layout/base.html file which has some basic structure, and it calls header & footer files. But intead of calling my scripts this way: <link rel="stylesheet" href="/css/bootstrap.css"> I do it with the twig include ...


1

Leowebguy pretty much nailed it. I made a scaffold for setting up craft with Foundation 6 if you want to peek through it. Its the same idea, but I've done all the set up for your gulpfile and such if you want to use SASS or any preprocessing. It's a bit different that Bootstrap, as they use grunt by default if I'm not mistaken, but figured I would throw in ...


1

To add a row at every 4th item, you can use twig's batch filter: Twig Batch Alternatively(a little more hacky) you can do {% if loop.index is divisible by(4) %} stuff {% endif %}. But batch is probably better.


1

Craft doesn't use themes, in the way WordPress does, so you won't find a direct equivalent to Roots / Sage. That said, none of what you listed is CMS-specific, so there's nothing stopping you setting up a generic development / build workflow which matches your stated requirements. Stack Overflow is a better place to ask about general tooling, though.


1

This is how I re-created Businessweek category page. It's not perfect, but you can start from there: {% paginate craft.entries.section('news').relatedTo(category).limit(17) as pageInfo, paginatedEntries %} {% set firstTwo = paginatedEntries|slice(0,2) %} {% set secondThree = paginatedEntries|slice(3,3) %} {% set lastFour = paginatedEntries|slice(6,10) %} &...


1

I think a way to achieve this, is to use a loop. If the pattern repeats after the third row, you could use odd or even. there might be a better way, https://mijingo.com/blog/where-am-i-in-the-twig-loop UPDATE i tested it, it kinda works but unfortunately it skips the 3rd item like that, as well as there still needs to be a solution for changing the ...


1

I was able to figure out how to get this working...See the following.. {% set entries = craft.entries.section('homepage, page').find() %} {% nav navItem in entries %} <li class="nav-item{{ navItem.id == entry.id ? ' active' }}"> <a class="nav-link" href="{{ navItem.uri }}">{{ navItem.title }}</a> </...


1

Craig, I really don't know much directly about this, but it occurred to me to look at the ConsoleApp, which is used in one normal way to run Craft headless (from yiic on command line). It's in app/etc/console/ConsoleApp.php. A little hunting around with PhpStorm, excellent for this sort of thing as others, turns up that ConsoleApp is loading plugins, and I ...


1

This issue won't be related to the Matrix field or the twig tags outputting it - check the CSS thats being applied. Are you wrapping your columns in a div with a class of .row? UPDATE: test by creating a new template and set it up with the following (replace the first line with the entry you're using: {% set entry = craft.entries.section( 'homepage' )....


1

Maybe an edge case, but if you're using the Kint logging/dumping extension for Craft in your console command, be careful. I got the undefined index SERVER_NAME error trying to to save an entry and output success/fail: d(craft()->entries->saveEntry($entryModel)); --> SERVER_NAME index error This fixed it: $save_result = craft()->entries->...


1

Indeed... this will do it: $craft = require '../other/craft/app/bootstrap.php'; $entry = $craft->entries->getEntryById($id); echo 'Other Craft install entry title:'.$entry->title;


Only top voted, non community-wiki answers of a minimum length are eligible