Hot answers tagged

9

It's not a log per se, but you can check out the craft_assetindexdata table of your database. That will show you all of the assets which Craft has indexed. You can see how far Craft has gotten by taking a look at the recordId column - all of the already indexed entries are going to have a value in that column while the records still waiting to be indexed ...


5

Forgive me if I'm wrong... by using loop.index0 is divisible by(2) are you trying to determine if the instance is odd or even? 1st - returns false 2nd - returns true 3rd - returns false 4th - returns true If so Twig does support checking if the loop index is even or odd. Perhaps that would be better to use? {% if loop.index is even %}Even{% endif %} EDIT ...


5

I finally found the answer to this question. From BaseElementType defineAvailableTableAttributes() docs, The first item that this array returns will just identify the database column name, and the table column’s header, but will not have any effect on what shows up in the table’s body. That’s because the first column is reserved for displaying ...


5

That’s definitely the way to do it! I would set the URL segments to their own variables, to clean it up a little bit. {% set entrySlug = craft.request.getSegment(2) %} {% set imageOffset = craft.request.getSegment(4) - 1 %} Also, probably a good idea to include the section param when fetching the entry, in case you have another entry in another section ...


5

Hat-tip to Brad for finding this answer. This can be achieved with something like the following in your index.php: define('BRADS_FAVORITE_HOBBY', "Drinking"); Thanks to the power to Twig, you can then access this in your templates using: {{ constant('BRADS_FAVORITE_HOBBY') }}


4

These are the settings I have in place for config.php and .htaccess file.


4

Providing you have the necessary permissions to do this, the following in your .htaccess should do the job: RewriteCond %{HTTP_HOST} !^domain\.co\.uk$ [NC] RewriteRule ^(.*)$ http://domain.co.uk/$1 [R=301,L] In place, the full file will probably look something like this: <IfModule mod_rewrite.c> RewriteEngine On # Redirect to non-www domain ...


4

What you want is not the loop variable of the inner loop around the image, but the loop variable of the outer loop. To get to the outer loop, use loop.parent. Try this: {% if loop.parent.loop.index0 is divisible by(2) %}last{% endif %}


4

In this case, the Apache mod_rewrite module wasn't installed, so the <IfModule mod_rewrite.c> block of Craft's default .htaccess file was being skipped not allowing index.php to be rewritten in the URL.


4

I would use macros. A Twig macro is basically a function, that can take arguments and render HTML. Macros can be defined inline (i.e. in the same template where it's used) or in a separate file (better if you're writing a generic macro that'll possibly be used in several different templates). Here's how your template could look, using macros: {% macro ...


3

This is what I ended up with which works great for me. $ses = craft()->assetIndexing->getIndexingSessionId(); $src = craft()->assetIndexing->getIndexListForSource($ses, 7); for ($i = 1; $i <= $src['total']; $i++) { craft()->assetIndexing->processIndexForSource($ses, $i, 7); }


3

After seeing this and hitting the same problem ourselves, we decided to create a plugin to index the assets from S3 in batches. We have not yet moved to using tasks in the plugin but it is on our roadmap. We know that Craft 3.x will have improvements to asset indexing but until then, please feel free to give our plugin a go if you are still experiencing ...


3

Your best bet for a quick hacky solution would be to interrupt the indexing process, take a look at craft_assetindexdata table and then write a small plugin that calls craft()->assetindexing->processIndexForSource(). You would get the sessionId from the craft_assetindexdata table and you'd be able to deduce how far the indexing has gotten by looking at the ...


3

Since files that begin with a dot are hidden by default in Unix-based systems like OS X, Craft ships with a “htaccess” file rather than “.htaccess”. If you are using Apache and want to use this file, you need to rename it to .htaccess when you upload it to your web server. Not sure why suddenly your site stopped working, but I can tell you that Craft auto-...


3

I hope you figured it out however, I just found adding RewriteBase / right under RewriteEngine On fixed my issue.


3

This has happened to me in a couple scenarios: When I am working across multiple environments and forgot to sync assets properly. (i.e. I pulled down the database snapshot from production, but not the newer assets that would be referenced in its Assets index). When one environment uses a case-sensitive file system (e.g. a unix host), and one uses a case-...


3

For the second part of your question, look into Element Sources. You might be able to pull off something fancy in a module, where certain users have access to different sources. For the first part of your question, look into the EVENT_REGISTER_TABLE_ATTRIBUTES and EVENT_SET_TABLE_ATTRIBUTE_HTML events. Here is a rough example of how it will look... // Add ...


2

Solved! I found the answer here: https://stackoverflow.com/questions/7670561/how-to-get-htaccess-to-work-on-mamp The problem was an Apache config setting. The solution was this: Went to httpd.conf on /Applications/MAMP/conf/apache In httpd.conf, found: Options Indexes FollowSymLinks AllowOverride None Replaced None with All. Restarted MAMP ...


2

I'd put money on your .htaccess file. Could be a permissions issue or maybe you misspelled .htaccess when renaming it? (The Craft distro comes without the period.) That's certainly happened to me—it's easy to do that (.htacccess anyone?) and then overlook everything else... If you're using a recent version of MAMP (and not MAMP Pro), it also gives you a ...


2

You should have the setting 'omitScriptNameInUrls' => true on either both sites, or in the wildcard config. <?php return [ '*' => [ // ... 'omitScriptNameInUrls' => true, // ... ] ]; You can read more about it here: https://craftcms.com/support/remove-index.php


2

As soon as you apply .all(), the variable you're working with becomes an array. Which means that the .offset(2) needs to be applied before you convert it into an array. UPDATE As @andrew.welch points out in the comments, it's as easy as grabbing the third item in your array... items[2] Ultimately, it looks like you want something like this... {% set ...


2

You can use the slice filter but it will return an array, so you either have to loop the result or access the first index {% for item in array|slice(1, 1) %} {{ dump(item) }} {% endfor %}


2

There's an easier way... Twig has a built-in variable in for-loops called loop, which has loop.index and loop.index0 properties which output exactly what you're looking for: https://twig.symfony.com/doc/3.x/tags/for.html#the-loop-variable {% for project in sliderWork %} <div class="progress__wrap"> <span data-slick-index="{{ ...


1

I don't know whether you've seen the batch Twig filter? You may find if useful to accomplish exactly what you are trying to do, but with a little bit less hassle. From the example in the link above: {% set items = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] %} <table> {% for row in items|batch(3, 'No item') %} <tr> {% for column in row %} ...


1

Could you double check your General Settings (Settings > General) to make sure there's no "/index.php" in the Site URL field?


1

Well, this isn't a Craft issue. You can submit a URL to be indexed via the "render" tab in Google Search Console. IIRC not all will necessarily be indexed straight away, even if submitted by itself, it may take time. You might find more info on this on the Webmasters Forum: https://productforums.google.com/forum/#!forum/webmasters


1

Just because Google has not indexed your pages doesn't mean there isn't necessarily anything wrong. Have you gone into the group Google search console to see what pages it has actually consumed? Also, you might consider trying SEOmatic to handle your SEO: https://github.com/nystudio107/seomatic


1

That error indicates a problem with the data in your database. The craft_assetfolders table has a parentId column that is a foreign key reference to its own id column. For whatever reason, that parentId column has a value that doesn't exist in any of the id columns, hence your errors. Some common causes include: Someone manually editing database values. ...


1

in the end, for me making /opt/www/dave/web/tmp writable for craft was the solution. thanks for all the feedback!


1

Craft has always updated the search index automatically after an entry is saved. The exact time it does that depends on what version of Craft you are using, and how the entry is being saved (web or CLI), but generally speaking there should never be a need to manually or programmatically update the search index yourself after saving an entry.


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