The grammar says that a German vowel is long if it is followed by a single consonant. So I think this word * Ökologie* should be pronounced as /ø ː ko ː lo ː ɡiː/, because every vowel in it is followed by a single consonant. But in wiktionary its pronunciation is /økoloˈɡiː/. So is it true that only accented vowels will be pronounced long?
Vowels such as /o/, /ø/ or /i/ are called long or tense and stand in opposition to /ɔ/, /œ/, /ɪ/, which are called short or lax.* As the chosen IPA symbols indicate, these phonemes differ by quality. Only the (phonemically) long or tense vowels can be realised as phonetically long, i.e. /o/ can be realised as [oː], but /ɔ/ cannot be realised as [ɔː]. Therefore, Ökologie is a word with three (phonemically) long vowels, although only the stressed vowel is realised as phonetically long.
As you surmised, long or tense vowel phonemes will typically be realised as phonetically long in stressed syllables. Compare the difference between Ökologie [økoloˈgiː] and Öko [ˈøːko], the latter with stress on the first syllable and /ø/ realised as [øː] where the former has [ø] (the base for both is /øko/).
With regard to the rule your grammar gave, it presumably wanted to hint at the contexts in which (phonemically) long or tense vowels occur. For certain examples, the rule might work: O-fen has /o/, of-fen has /ɔ/. For others, it might not: von has /ɔ/, lobt has /o/. That is, in reality it's much more complicated.
One further complication: German allows reductions of long or tense vowels to short or lax vowels (with speakers differing widely in their judgements as to what is admissible in the standard language). For instance, I'm pretty sure that I often pronounce Ökologie as [œkɔlɔgˈiː]. These reductions can become phonemic: Politik can be /-ˈtik/ as well as /-ˈtɪk/.
* Some phonologists prefer the opposition long vs. short, others tense vs. lax. The important thing is that one binary feature suffices.
This rule is true for Erbwörter (sorry, I don't know the english term. Maybe "inherited words"?). These are words that are part of German language since it started to exist (how ever you define that date), like Wasser, Vater, reiten, gehen, ...
Erbwörter usually have two syllables. The first syllable is stressed, the second is unstressed. But there are also Erbwörter with only one syllable (der, ich, es, nicht, Hand, Fuß, ...)
The rule that two or more consonants at the end of a syllable indicate a short vowel while all other vowels are long holds only for Erbwörter with two syllables. But even monosyllabic Erbwörter have so many exceptions, that it's hard to tell if this rule even applies for them.
And there is no reason why other languages than German should follow German grammar rules. So, it makes no sense to apply this rules to foreign words and to loan words.
As @Roland already said in his comment "Ökologie" is a greek loan word. The greek language has two different kinds of "o", the "small o" and the "large o": omikron ("Ο" "ο") and omega ("Ω" "ω").
The "ö" in "Öko" is originally written with "οι" (omicron, iota) and a diphtong, whereas the second "o" is an "ο" (omicron). Because for diphtongs there are different rules the first vowel is pronounced long, because the second vowel is an omicron its pronounciation is impliedly short.
PS: notice, that "omicron" and "omega" are names given to these vowels only in byzantinian times, when both "o"-sounds where pronounced the same way. In classical times they were pronounced [oː] and [ɔː].